Javatpoint Logo
Javatpoint Logo

PrimeFaces Rating

It is a star based rating system. It is used to take user input as a rating. It is useful when we want to get user feedback. It is mostly used to get product rating.

Rating Attributes

Attribute Default value Type Description
required false Boolean It makes the component as required.
Validator null MethodExpr It is a method binding expression that refers to a method validating the input.
valueChangeListener null MethodExpr A method binding expression that refers to a method for handling a value change event.
requiredMessage null String It is used to set message to be displayed when required field validation fails.
converterMessage null String It is used to set message to be displayed when conversion fails.
validatorMessage null String It is used to set Message to be displayed when validation fields.
widgetVar null String It is a name of the client side widget.
stars 5 Integer It is used to display number of stars.
disabled false Boolean It disables user interaction.
readonly false Boolean It disables user interaction without disabled visuals.
onRate null String Client side callback to execute when rate happens.
style null String It is used to set inline CSS of the component.
cancel true Boolean It is used to cancel.

Example

Here, in the following example, we are implementing <p:rating> component. This example contains the following files.

JSF File

// rating.xhtml

ManagedBean

// Keyboard.java

Output:

PrimeFaces Rating 1
PrimeFaces Rating 2




Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA