Book Image

PrimeFaces Cookbook

Book Image

PrimeFaces Cookbook

Overview of this book

Table of Contents (20 chapters)
PrimeFaces Cookbook Second Edition
Credits
Foreword
Foreword
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Star-based rating input


The rating component provides star-based rating with the ability to select and cancel.

How to do it…

The basic declaration for the component would be as follows:

<p:rating value="#{ratingBean.rate}" />

Here, the rate value binding is a java.lang.Integer definition. The default visual of the component will be as shown in the following screenshot:

The stars attribute sets the number of stars to display with a default value 5.

There's more…

With the readonly attribute, it's possible to only display the value output of the component by disabling user interaction. When set to true, the cancellation button will also not be rendered on the left-hand side of the component.

When the disabled attribute is set to true, the rating component will act the same as when the readonly attribute is set to true, but the color of the stars will get faint, as seen in this screenshot:

Note

Currently, the rating component does not support half or quarter values.

AJAX behavior events

It is also...