Form - get buffered value

Hi,

My vaadin application has a form and a table. Both are connected to the same BeanItemContainer.

When the users clicks on a table row, it is displayed in the form, which is not in write through mode.

The form has also Edit, Save and Cancel buttons.

Save button will commit() changes and cancel wil discard(). Edit changes form.setReadOnly() state.

My question is: How can I get the forms buffered and possibly modified value before calling form.commit()?

If I use form.getValue() after commiting changes I can achieve it, but I need to get this value before commiting, to update my database, and then commit() would be called only if the db update is succesful. In case it is not successful I could easily cancel the changes by calling discard().

Thanks,
Diogo

You need to get the actual fields in the form and then call getValue() on the fields to get the buffered value. I’m not quite sure if this however is the best approach to solve your problem. If I would do what you’re doing, I’d probably create a
memento object
of the BeanItem, do a commit in the form, try to store it in the database, if it fails, then restore the bean item’s state by using the memento object.

Just my two cents.

  • Kim