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.
Active tab not preserved
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'
and a Listener Method in your Bean which sets the property with the proper value:
Code: Select all
<p:tabView activeIndex="#{bean.activeIndex}">
<p:ajax event="tabChange" listener="#{bean.onTabChange}" />
...
</p:tabView>
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();
}
primefaces 6.1 +++ myfaces 2.2.12 +++ weld 2.4.3 +++ tomcat 8.5.14 +++ java se 1.8.0_121-b13 +++ mac os x 10.12.4
- andyba
- Expert Member
- Posts: 2473
- Joined: 31 Mar 2011, 16:27
- Location: Steinfeld, near Bremen/Osnabrück, DE
- Contact:
@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
PF 4.x (Elite versions), PF 5, Pf 5.1, PF 6.0
Glassfish 4.1, Mojarra 2.x, Java 8, Payara 4.1.1.
If you haven't read the forum rules read them now
Glassfish 4.1, Mojarra 2.x, Java 8, Payara 4.1.1.
If you haven't read the forum rules read them now
-
- Information
-
Who is online
Users browsing this forum: No registered users and 14 guests