Ask the user to save a from on TabChange

Hi,

in my application I have different forms on the tabs of a TabSheet with a “save” button on each of the forms.

If the user changes the tab and there are unsaved data in the current form, I want to display a message to ask the user to save or discard the changes.

Is there any way do do this?

I tried to add a SelectedTabChangeListener to my TabSheet… but if I display a message there, than it is shown on the new tab after the change - and I can see no way to prevent the TabSheet from displaying the new tab.

Thank you for any hint!

Might not be an answer for you, but take a look of
Navigator
. In order to implement the similar behavior without Navigator add-on, peek the sources (they are just few hundred lines). For a demo, open
this demo application
, go to “MockupView” and then back to some other view.

You could have a base abstract tabs that each tab extends (or interface) ,then have a tabManager to manager the switching between them. This has to do more with design pattern than with vaadin UI component.