You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Daniel Watrous <da...@gmail.com> on 2012/01/23 19:18:35 UTC
How to customize RatingPanel markup
I've been trying to override the default RatingPanel markup, but I'm
having trouble. I found this:
http://apache-wicket.1842946.n4.nabble.com/How-to-override-RatingPanel-default-CSS-td1873783.html
I create the subclass:
public abstract class MovieRatingPanel extends RatingPanel {
public MovieRatingPanel(String id, IModel model, int
numberOfStars, boolean defaultCss) {
super(id, model, numberOfStars, defaultCss);
}
}
I then change the RatingPanel to MovieRatingPanel in my markup:
movieItem.add(new MovieRatingPanel ("rating", new
PropertyModel<Integer>(rating, "rating"), 5, false) {
@Override
public boolean onIsStarActive(int star) {
return rating.isActive(star);
}
@Override
public void onRated(int newRating,
AjaxRequestTarget target) {
movieItem.getModelObject().setRating(newRating);
rating.updateRating(newRating);
Session session =
HibernateUtil.getSessionFactory().getCurrentSession();
session.beginTransaction();
session.update(movieItem.getModelObject());
session.getTransaction().commit();
movieList.detach();
}
});
The markup is
<html xmlns:wicket="http://wicket.apache.org">
<head>
</head>
<body>
<wicket:panel>
<div class="wicketRating" wicket:id="rater">
<div class="wicketRatingStars"><span wicket:id="element"><a
href="#" wicket:id="link"><img wicket:id="star"/></a></span></div>
</div>
</wicket:panel>
</body>
</html>
I am getting the Exception:
Last cause: The component(s) below failed to render. A common problem
is that you have added a component in code but forgot to reference it
in the markup (thus the component will never be rendered).
1. [Component id = rating]
I'm not sure how to extend this so that I can simply replace the
default markup with my own. Any pointers?
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: How to customize RatingPanel markup
Posted by Geoff Lancaster <wi...@geofflancaster.com>.
You named the panel "rating" in your java but did not define "rating" in your html
Sent from my iPhone
On Jan 23, 2012, at 12:18 PM, Daniel Watrous <da...@gmail.com> wrote:
> I've been trying to override the default RatingPanel markup, but I'm
> having trouble. I found this:
> http://apache-wicket.1842946.n4.nabble.com/How-to-override-RatingPanel-default-CSS-td1873783.html
>
> I create the subclass:
>
> public abstract class MovieRatingPanel extends RatingPanel {
> public MovieRatingPanel(String id, IModel model, int
> numberOfStars, boolean defaultCss) {
> super(id, model, numberOfStars, defaultCss);
> }
> }
>
> I then change the RatingPanel to MovieRatingPanel in my markup:
>
> movieItem.add(new MovieRatingPanel ("rating", new
> PropertyModel<Integer>(rating, "rating"), 5, false) {
> @Override
> public boolean onIsStarActive(int star) {
> return rating.isActive(star);
> }
> @Override
> public void onRated(int newRating,
> AjaxRequestTarget target) {
> movieItem.getModelObject().setRating(newRating);
> rating.updateRating(newRating);
>
> Session session =
> HibernateUtil.getSessionFactory().getCurrentSession();
> session.beginTransaction();
> session.update(movieItem.getModelObject());
> session.getTransaction().commit();
>
> movieList.detach();
> }
> });
>
> The markup is
>
> <html xmlns:wicket="http://wicket.apache.org">
> <head>
> </head>
> <body>
> <wicket:panel>
> <div class="wicketRating" wicket:id="rater">
> <div class="wicketRatingStars"><span wicket:id="element"><a
> href="#" wicket:id="link"><img wicket:id="star"/></a></span></div>
> </div>
> </wicket:panel>
> </body>
> </html>
>
> I am getting the Exception:
> Last cause: The component(s) below failed to render. A common problem
> is that you have added a component in code but forgot to reference it
> in the markup (thus the component will never be rendered).
>
> 1. [Component id = rating]
>
> I'm not sure how to extend this so that I can simply replace the
> default markup with my own. Any pointers?
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org