Question

I have created tabs dynamically and I am trying to assign it attribute id which is not working.....or any other way to get the title of the clicked tab?

<p:accordionPanel value="#{displayassestDto.getgroups()}" var="d">
    <p:ajax event="tabChange" listener="#{displayassestDto.onTabChange}" update=":form:growl"/>
       <p:tab title="#{d.group}" id="tab_#{d.group}">
           <h:outputLabel value="Helllooo" />
            </p:tab>
</p:accordionPanel>
Was it helpful?

Solution

any other way to get the title of the clicked tab?

Yes, onTabChange can be modified to accept an object of type TabChangeEvent. On this object, you can retrieve the tab that fired the event. Your code will look something like

       public void onTabChange(TabChangeEvent evt){
            evt.getTab(); // on this tab object returned, you can get the id, title etc
        }

As to why the code you have is not working right now, it's probably because the state of the output of getGroups() is not consistent throughout the request processing. Ensure you're not carrying out any business logic or processing in getGroups(). But you really don't need to do any of that.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top