Event fired when selecting an already selected tab

Is there an even that is fired when selecting an already selected tab.

I want to implement a refresh feature that refreshes a tab’s contents if you click the tab when it is already opened.

There was another thread posted a few years ago on the same topic but left unresolved: https://vaadin.com/forum/-/message_boards/view_message/311414

I tried the suggestion and ran across the same issue as that poster; overriding setSelectedTab(Component c) does not help because the method is still not called on tab click.

Maybe there is some other event for registering a click or something on the tab?

I hope this makes sense

Hi,

unfortunately I think this is not easily possible. The client side widget does not even send a tab-selected-event if the active tab is clicked again. You can see the code for yourself in VTabSheet.onTabSelected(…) method, look at the third if clause. As this is a private method, a simple override isn’t possible.

If you can think of a solution, please do post it here as it might be useful to others too.

In reply to above, if anyone else is wondering:

In VTabSheet, line 632 (version 6.8.2):
private boolean onTabSelected(final int tabIndex) {
Tab tab = tb.getTab(tabIndex);
if (client == null || disabled || waitingForResponse) {
return false;
}
if (!tab.isEnabledOnServer() || tab.isHiddenOnServer()) {
return false;
}
if (activeTabIndex != tabIndex) { // <------- only if selected tab is different than focused tab
// send change event to server side

}
}

Since this is client side I don’t know if extending the class to override the functionality or anything like that would work either. I was thinking something like a “click” variable change could be sent and then accepted by TabSheet or an extension of it.

Either way, I think we have decided to not go with the onTabClickRefresh method in favor of something more traditional like a refresh button in each tab that needs content refresh.