I have a ComboBox that allows new items and is set to immediate.
If the user types a new value, a Button’s caption on the same window is changed from “Load” to “Save” by the ValueChangeListener method.
Works great.
…except in IE,
if the user types a new value, then clicks the “Load” button directly, both the blur event (ValueChange from the ComboBox) and the click event are fired together without the intervening round-trip (that would allow the ValueChangeListener to set the Button’s cation to “Save”).
It works, but to the user, it looks like they pressed a “Load”.
In Firefox there are two round trips, so when the user first clicks the “Load” button (directly after typing a new value), the ValueChangeListener is called, the Button changes to “Saved”, then they have to click again.
The work around I came up with was to time the difference between the two events, if it’s less than a threshhold (100ms) I assume a double event, and can simulate Firefox’s functionality.
First off: It sounds that you have encountered the same thing that I have: IE doesn’t send a “value changed” javascript event on field blur (which then triggers a ValueChangedListener). I’ve had a small talk about this with Artur, and it sounded like they will be looking into this, and thinking about whether the behavior can be fixed to be similar in all browsers. But don’t hold your breath on this one.
But, it sounds that your solution “happens to work” at the moment. With a faster Internet connection, webserver and/or Firefox version, that threshold might not be enough. I’d suggest you doing one of two things: explicitly check whether the given item really is new or not, regardless of what “state” your Button is, or then just have separate “Load” and “Save” buttons, with separate ClickListeners.
Actually this was related to that IE does not send an onchange event when you press enter in a text input. Not related to this issue or blur events at all.
I cannot help but wonder if it isn’t a bit confusing for the user to click the “load” button to save as it still says “load” when you click it no matter what is says while actually saving… Anyway, the events might be joined or not depending on the browser and the situation. What is guaranteed is that the value change event is fired (on server side) before the button click event. For a long running request there is always the possibility to start a background thread to do the work (e.g. save) and then update the UI when the background work is done (using Refresher/ICEPush or similar)