Hi,
Observed with Vaadin version 7.2.0, same code works fine with &.1.14
In my application there are 5 tabs, each tab contains some components.
Following is the desired functinality:
- Tab at position 0 is set as selected by default
- User click on tab at postion 4
- Now depending on some business logic it will be checked if all operation on tab at position 0 are completed or not
- If operations on tab at position 0 are not completed then setSelectedTab(0)
Issue:
- When setSelectedTab(0) is used all tabs in tabsheet becomes unresponsive, tabs are clickable but tab containt is not loaded.
- This scenarios fails only when Tab at position x is selected where x=0 at then user clicks on Tab 5
- If user has selected Tab at position y, where y!=0 code works fine
Please suggest how to solve this issue.
Following is the code for reference:
package com.example.vaadindemo;
import com.vaadin.server.VaadinRequest;
import com.vaadin.ui.Label;
import com.vaadin.ui.Notification;
import com.vaadin.ui.TabSheet;
import com.vaadin.ui.TabSheet.SelectedTabChangeEvent;
import com.vaadin.ui.TabSheet.SelectedTabChangeListener;
import com.vaadin.ui.UI;
import com.vaadin.ui.VerticalLayout;
@SuppressWarnings("serial")
public class TabsheetDemo extends UI {
@Override
protected void init(VaadinRequest request) {
final VerticalLayout vLayout = new VerticalLayout();
final TabSheet tabsheet = new TabSheet();
final VerticalLayout tab1 = new VerticalLayout();
final VerticalLayout tab2 = new VerticalLayout();
final VerticalLayout tab3 = new VerticalLayout();
final VerticalLayout tab4 = new VerticalLayout();
final VerticalLayout tab5 = new VerticalLayout();
tab1.addComponent(new Label("Label A"));
tab2.addComponent(new Label("Label B"));
tab3.addComponent(new Label("Label C"));
tab4.addComponent(new Label("Label D"));
tab5.addComponent(new Label("Label E"));
tabsheet.addTab(tab1, "Tab 1");
tabsheet.addTab(tab2, "Tab 2");
tabsheet.addTab(tab3, "Tab 3");
tabsheet.addTab(tab4, "Tab 4");
tabsheet.addTab(tab5, "Tab 5");
tabsheet.setSelectedTab(0);
tabsheet.addSelectedTabChangeListener(new SelectedTabChangeListener() {
@Override
public void selectedTabChange(SelectedTabChangeEvent event) {
if (tabsheet.getSelectedTab().equals(tab5)) {
boolean flag = false;
// TODO flag = ifOperationsOnTabDone(){.....}
// Some business logic to check if the operations on current
// selected tab completed or not
if (!flag) {
// Set focus back to first tab in tabsheet
tabsheet.setSelectedTab(0);
Notification.show("Focus set back to tab at position 0");
}
}
}
});
vLayout.addComponent(tabsheet);
vLayout.setWidth("400px");
vLayout.setHeight("300px");
setContent(vLayout);
}
}
Regards,
Kunal Patil