Activate (show) tab on button click

Hi,

I would like to make a wizard-like interface based on a tabsheet with multiple tabs that opens / shows the next tab when clicking the ‘Next’ button. I manage to get the current tab and find to identify the next tab but there seems no option to ‘activate’ (show) it.

Is there a way to do this?

window xml (stripped):


<tabSheet id="tabs">
    <tab id="first"
         caption="First"
         margin="true,false,false,false">
              <label caption="First"/>
    </tab>
    <tab id="next"
         caption="Next"
         margin="true,false,false,false">
              <label caption="Second"/>
    </tab>
    <tab id="last"
         caption="Last"
         margin="true,false,false,false">
              <label caption="Third"/>
    </tab>
</tabSheet>
<button caption="Next" invoke="nextTab"/>

And nextTab() function (stripped as well):


public void nextTab() {
    String next;
    switch (tabs.getTab().getName()) {
        case "first":
            next = "next";
            break;
        case "next":
            next = "last";
            break;
        case "last":
            next = "first";  // Loops the tabs
            break;
    }
    tabs.getTab(next).activate(); // ???!! Would be nice to do something like this...
}

Any help appreciated.

Hi,

My bad, it was actually very simple:


tabs.setTab(next);

Apologies for asking.

Hi,
you right, setTab() method is used to set selected tab.

Hi,

setTab() is deprecated.
What’s the way to do it now?

According to the platform-implemenation (com\haulmont\cuba\gui\components\TabSheet.java) it should be setSelectedTab() now.

2 Likes

Hi Berend

Ok I see, new methods setSelectedTab() and getSelectedTab()
I get it, Thanks