You can try to use the activeIndex attribute of the accordionPanel which is the index of the active tab.
<p:accordionPanel activeIndex="#{playgroundController.activeIndex}">
<p:ajax event="tabChange" listener="#{playgroundController.onTabChange()}" />
<p:tab title="Godfather Part I">
<h:panelGrid columns="2" cellpadding="10">
<h:outputText
value="The story begins as Don Vito Corleone..." />
</h:panelGrid>
</p:tab>
<p:tab title="Godfather Part II">
<h:panelGrid columns="2" cellpadding="10">
<h:outputText value="Francis Ford Coppola's legendary..." />
</h:panelGrid>
</p:tab>
<p:tab title="Godfather Part III">
<h:panelGrid columns="2" cellpadding="10">
<h:outputText value="After a break of more than 15 years..." />
</h:panelGrid>
</p:tab>
</p:accordionPanel>
Bean:
private String activeIndex = "";
public void onTabChange() {
logger.debug("onTabChange : activeIndex : {} ", activeIndex);
}
While clicking on one of the tabs it prints:
09:38:55,822 DEBUG [PlaygroundController] onTabChange : activeIndex : 0
09:38:56,625 DEBUG [PlaygroundController] onTabChange : activeIndex : 1
09:38:57,426 DEBUG [PlaygroundController] onTabChange : activeIndex : 2