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.
Create a
TagCloud
component to display tags and aDataList
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>
Implement methods to get tags and posts by a selected tag.
public class TagController { private BuzzService buzzService; private static Random random = new Random(); private TagCloudModel model; private List<Post> posts; public TagController...