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 – choosing a tag in TagCloud with the select Event

In this section we will create a TagCloud component and display posts based on the selected tag.

  1. Create a TagCloud component to display tags and a DataList component to display posts associated with that selected tag:
    <p:tagCloud model="#{tagController.model}">
      <p:ajax event="select" update="posts"listener="#{tagController.onSelect}" />  
    </p:tagCloud>
    <p:panel header="Posts by Tag">
      <p:dataList value="#{tagController.posts}" var="post" id="posts" type="none">  
        <h:outputText value="#{post.title}"/><br/>
        <h:outputText value="#{post.description}"/><br/>
        <p:separator/>
      </p:dataList>
    </p:panel>
  2. Implement methods to get tags and posts by a selected tag.
    public class TagController { private ...

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