Handling unsaved changes in dialogs

Hi,

in our application, we enter data in several places within dialogs (sometimes nested dialogs). We would like to display a message about unsaved data if the user made an input in the current open dialog.

Since we use partially nested dialogues we cannot listen to any navigation events. Is it possible to recognize all ValueChangeEvents of the active dialog or do we have to manually add a ValueChangeListener to each binder/field which determines the unsaved status?

If it helps, I add a valueChangeListener to the Binder and then iterate though the fields in the Binder to set the ValueChangeMode to Eager.


binder.addValueChangeListener(listener -> { 
	log.debug("a value has changed");
});
		
...

binder.getFields().filter(field -> field instanceof HasValueChangeMode).forEach(field -> ((HasValueChangeMode) field).setValueChangeMode(ValueChangeMode.EAGER));

But yes, I think you’ll have to add a ValueChangeListener to every binder in your dialogs.

Stuart