I have Primefaces TabView with two Tab like:
<p:tabView dynamic="true" cache="false"
onTabShow="scrollBottom(#{stanzaBean.activeIndex})"
tabChangeListener="#{messaggioBean.onTabChange}"
activeIndex="#{stanzaBean.activeIndex}" >
it works fine, except that when I change the Tab the activeIndex isn't updated on the Server and it returns always the default value.
I'm using primefaces 2.2.1.
Thank you.
Best Answer
Going by the PrimeFaces ShowCase example, if you give each tab an id:
you can get that tab id in the tabChangeListener.
Then you'll know which tab was selected.
Edit:
There is an open PrimeFaces issue 1640 TabView: Wrong activeIndex in TabChangeListener, always 0 on the problem you are having.
Edit 2:
With PrimeFaces 5.0 and up the
tabChangeListener
is no longer available on thetabView
element but should be used via an explicit ajax tag with a tabChange event.Also you can directly get index of tab:
with all these changes, activeIndex works properly.