Form submit with ValueChangeMode.LAZY

Hello,

When using ValueChangeMode.LAZY, how do I guarantee that when a user clicks a save/submit button in a form the values that the user sees have been synced to the backend and are saved properly? For example, take the tutorial https://github.com/vaadin/tutorial/tree/vaadin10%2B and in CustomerForm.java put

firstName.setValueChangeMode(ValueChangeMode.LAZY);

Then click “Add new customer”, type something in the “First name” and click the save-button very fast. The form is saved without the data that was typed in the field. How to fix this?

One thing you could try is to set firstName.setValueChangeMode(ValueChangeMode.EAGER); in save buttons click listener to enforce flushing of the value.

Thanks for the suggestion, but it did not help. Perhaps the lazy-mode just should not be used in forms.

Does Vaadin have some mechanism in place for the other value change modes to prevent this problem (i.e. what the user sees on the browser is not what is actually saved by the backend) ? Is it possible that this problem can happen with the other modes as well when network connection is poor or something?