setValue called after update of field

Hi

I have created my own class that implements Property and another class that extends PropertySetItem and adds my Property.

When I create a Form from my Item class, I find that the setValue method of the Property implementation is only called when the form is reloaded (by pressing refresh in my browser). This is not really the behaviour I want.

So, my questions are:

  • Are there any way to programattically “force” a call to setValue, i e so that the data is copied from the form to the Item?
  • Can I set up my Form so that setValue is called whenever the user leaves the control in question, i e the focus shifts out from the control to somewhere else?

Regards
/ Fredrik Ferm

Call

form.commit();

This should do the trick:

form.setWriteThrough(true);
form.setImmediate(true);

Note that you need to call these again e.g. if the fields are regenerated, so it is best to call these right after (re)setting your data source.

If the form is not immediate, UI changes are queued until there is an immediate event, such as clicking a button. Setting the immediate and write-through flags for a form also set the same flags for the fields on the form.