ValueChangeListener for TextField, ComboBox

I realise I can get the answer by reading the source code or by testing it out, but I am hoping someone might have already done it.

I have ValueChangeListener instances coupled to some TextField, ComboBox objects.
If a value did not change, I would not commit the values to the database.

My question is on how modification is detected. Is it by detecting key/mouse clicks.

Let’s say we have a TextField captioned Religion. The data fetched from the db is “Atheist”. Then the fickle-minded user modifies it to “Islam” and then back to “Atheist”.

Similarly, with a combobox.

In either case, is the ValueChangeEvent fired?

If the field is immediate (setImmediate(true)) then a blur even will trigger the check for valuechangeeveent. Blur here means that the focus is changed - the user clicks outside the field or presses tab/enter etc. So if the user types in ‘islam’ → clicks somewhere else → types it back to atheist → clicks somewhere else; you’ll get two valuechangeevents. Of course there won’t be a valuechange event if the focus is always on the field, and the user just changes the value back and forth so that the original value is the same as when the user clicks outside the field.

It is another deal if the fields are not immediate. I’m not exactly sure how they work, as I always use immediate, but the deal is that all the events will go at the same time when something triggers it - like a button click or one immediate field. This will not trigger then a value change event in case one anymore.

Hope I wasn’t too confusing! :slight_smile:

thx for the response but my fields are not immediate as I want the user to prowl up and down the form before submitting for update to the database. Rather than immediate update every time the user changes each field, as that would mean a lot of database communication overhead.

However, I placed at the field property commit to check for changes. I was hoping not to duplicate such checks if valuechangeeveent had already done it.