In an application based on Vaadin 8 I want to implement a Command that remove the value of all fields. I have done this Using Binder. When user is activating the command a new Bean will be created.
@Override public void menuSelected(MenuBar.MenuItem selectedItem) {
controller.createNewBean();
Page.getCurrent().reload();
}
I want to show a message box to the user which warns that by proceeding all values for all components will be lost. I am using a TabView and there are relatively many components.
I want to show this message only if user has changed a value for at least one component.
I wonder if Vaadin has something like UI.getCurrent().isDirty() or another mechanism to determine if user has entered a new value to a component?
Thanks for help
You may want to use
binder.hasChanges(). This basically checks whether your fields and the underlying bean bound to the fields differ because of user interactions.From Vaadin's Docs:
See Vaadin's API and Vaadin Doc's chapter Binding Data to Forms for more information.
With
Page.getCurrent().reload()you get a new UI and all your components are reset as if you opened a new tab. For resetting your components I would recommend to usebinder.readBean(theNewBeanWithFreshValues). This sets the values of the bound fields back to the values of the bean.