Tabsheet: prevent tab change event

Hi Vaadin Team,

i like to prevent the user from switching a tab to an other tab.
In some cases i have validations that forbids a tab change.
Is there a way to lock/disable a tab.

thx Jonas


yes, there are two ways:

First, get the Tab by calling
TabSheet.getTab(Component c)

Then with the TabSheet.Tab object you have now, just call setEnabled(false); to it to set it non-selectable or setVisible(false) to hide it completely from view.


Thanks, it is easier than it seems :slight_smile:

how can i show warning message while user tries to select another tab.

You can add a SelectedTabChange event listener to the tab and show the message there.

while the tab is disabled will it fire SelectedTabChange event ? it will be a non-selectable tab.

If a tab is disabled, the user can’t select it. I don’t remember how it works on the server, you might still be able to select the tab programmatically.

That is fine. But when the tab is disabled and user tries to select it I want to show a warning message to user. Is there any way I can achieve that !!

How to get tab select listener event in Tabsheet

tabSheet.addSelectedTabChangeListener(new SelectedTabChangeListener() {
  public void selectedTabChange(SelectedTabChangeEvent event) {


When a tab is disabled, its content is also disabled. Is there a way to disable the user from switching tabs without disabling all the content of the tab?
I have a number of buttons in the tabs, and setting enabled to false for the tab, disable those buttons too.