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 – using the Rating component

Let us see how we can use the Rating component with 10 stars and use the rate and cancel AJAX event listeners:

  1. Create a Rating component and register the AJAX listeners for the rate and cancel events, using the following code:
    <p:growl id="growl"/>
    <p:rating value="#{postController.selectedPost.rating}" stars="10">  
      <p:ajax event="rate" listener="#{postController.handlePostRating}" update="growl" />  
      <p:ajax event="cancel" listener="#{postController.handlePostRatingCancel}" update="growl" />  
    </p:rating> 
  2. Implement the event listener methods:
    @ManagedBean @RequestScoped public class PostController { private Post selectedPost; //setters and getters public void handlePostRating(RateEvent rateEvent) { Integer ...

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