Wicket Ajax Rating Component
I just committed an Ajax Wicket component for rating stuff, similar to the Votio wordpress plugin.

The links are rendered as Ajax links, which also provide a fallback in case Ajax isn't available. This way the vote almost always gets through. The component renders itself when the ajax request returns, and as a component user, you can also update other components yourself in the same request.
Adding the rating component should be as simple as:
Rating ratingModel = new Rating();
add(new RatingPanel("rating", new PropertyModel(ratingModel, "rating"), 5))
{
protected boolean onIsStarActive(int star)
{
return ((RatingModel)getModelObject()).isActive(star);
}
protected void onRated(int rating, AjaxRequestTarget target)
{
((RatingModel)getModelObject()).addRating(rating);
}
});
and in your markup all you have to do is:
where you want your rating box to go.
All you have to supply is your own implementation of a Rating object, which will keep track of the number of votes, averages the votes, and creates a rating.
Features of the rating component:
- use your own icons for the images
- allow a user to vote only once (the implementation is up to you)
- customize the styling
- customizable rating system (it's all in the model, so ratings from 1-10, 1-5, F-A, are all possible)
- label showing the absolute value of the rating (3.7 from 5 votes) can be turned off, or replaced with your own implementation
The component will be part of wicket-extensions-1.2.1 (the next maintenance release of Wicket).