Page 1 of 1

Active tab not preserved

Posted: 24 Sep 2011, 00:23
by primefaceshack
I have a page with three tabs (tab1, tab2, tab3) and each tab I have a datatable that contains a hyperlink on the first column. If I am on tab2 and click the hyperlink, it takes me to a different page containing a back hyperlink. When I click on the back hyperlink, it goes back to the previous page but the active tab is not 'tab2', it is default to 'tab1'. Can someone please tell me how to code to make the active tab is 'tab2'.

I am using PF 3.0-M3.

Thanks in advance.

Re: Active tab not preserved

Posted: 25 Sep 2011, 17:18
by primefaceshack
Anyone, please?

Re: Active tab not preserved

Posted: 25 Sep 2011, 23:57
by kukeltje
You asked this on saturday and expect an answer on sunday... It IS weekend you know... Patience is a virtue

Re: Active tab not preserved

Posted: 07 Feb 2013, 16:47
by bubi
To preserve the Tab Index between several Updates use the activeIndex attribute for the TabView component to set the activeTab. To save the active Tab use a <p:ajax> element for the event 'tabChange'

Code: Select all

<p:tabView activeIndex="#{bean.activeIndex}">
        <p:ajax event="tabChange" listener="#{bean.onTabChange}" />
...
</p:tabView>
and a Listener Method in your Bean which sets the property with the proper value:

Code: Select all

private int activeIndex; // +setter/getter

public void onTabChange(TabChangeEvent event) {
        Tab activeTab = event.getTab();
        TabView parent=(TabView)activeTab.getParent();
        activeIndex=parent.getActiveIndex();
}

Re: Active tab not preserved

Posted: 07 Feb 2013, 17:21
by andyba
@Bubi: have you read the Forum rules recently? There is at least one which says, and I am paraphrasing here,
Thou shalt not dig up very old Threads and play with them because they smell of corpses and Andyba has a very sensitive nose

Re: Active tab not preserved

Posted: 07 Feb 2013, 18:18
by kukeltje
ROTFLOL