Skip to end of metadata
Go to start of metadata

The rating tag component is a visual component that renders plain HTML content that is further enhanced using javascript to display the typical rating stars:

The component may be used to introduce data in a form or to display read-only data.

Rating inside a form

To use inputRating inside a form, just use it as any other field-bound component:

The action class:

This example will extract the current total amount and number of votes (to calculate the average value) and store the user-submitted vote in VoteAction.vote.

Generated HTML

InputRating will render an enhanced <l:select> tag. The list of possible values can be injected using the options attribute, but the usual way is to just inject a max value and let it calculate the options automatically. It set using NumberValidation, the scale (number of decimals) applied when calculating the average will be the same of the field, default 1.

If the field is set to translate the labels, the messages.properties file should contain the corresponding entries:

With this JSP content:

Will generate the following HTML snippet:

To add the javascript component, refer to the Rating javascript component page.

Read-only rating

When the name property is not set, inputRating will only display the current rating value and the user cannot cast a new vote. This is different of setting disabled to true, as it will not render a select field:

After adding javascript, this will render the same as a normal, disabled rating component.

Adding javascript

To replace a select field with the typical stars, add the following to the end of your JSP page:

The component can be enhanced with optional arguments, such as set submitOnVote to true to automatically submit the form after voting.

When moving the mouse over a rating component, the message will display the label of the corresponding selected option.


‹ MultiUpload
up
Recaptcha ›

Labels:
None
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.