O'Reilly logo

PrimeFaces Beginner's Guide by K. Siva Prasad Reddy

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action – creating AccordionPanel with dynamic tabs and event listener

Create AccordionPanel and specify to disable a tab if no posts are associated with the tag using the disabled attribute of the <p:tag> element:

<p:accordionPanel value="#{tagController.tags}" var="tag" activeIndex="2">
  <p:ajax event="tabChange" listener="#{tagController.onTabChange}"/>
  <p:tab title="#{tag.label}" disabled="#{empty tag.posts}">
    <h:outputText value="#{tag.description}" />
  </p:tab>  
</p:accordionPanel>

What just happened?

We have created an AccordionPanel backed by the List<Tag> collection. We have specified disabled="#{empty tag.posts}" to disable a tab if there are no posts associated with that tag. As there are no posts associated with struts and hibernate ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required