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 – displaying tags as TagCloud

Let us see how we can create a TagCloud component and initialize it with some sample Tag data.

  1. Create the TagCloud component using <p:tagCloud>:
    <p:tagCloud model="#{tagController.model}"/>
  2. Create the TagCloudModel object and populate TagCloudItem:
    public class TagController
    {
      private TagCloudModel model; 
      public TagController()
      {
        model = new DefaultTagCloudModel();
        model.addTag(new DefaultTagCloudItem("PrimeFaces", "/posts.jsf?tag=primefaces",5);
        model.addTag(new DefaultTagCloudItem("JSF", "#",3);
        model.addTag(new DefaultTagCloudItem("jQuery",2);
      }
    }

What just happened?

We have created a TagCloudModel object using DefaultTagCloudModel and populated TagCloudItem with various labels, urls, and strengths. For ...

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