What I have done to avoid to repeat the creation of the labels is to define and use static method
private Label labelTitle; public static Label getLabelTitle(String title) { return new Label("title",new Model( title )); } Joseph Pachod wrote: > > cmoulliard wrote: >> (...) >> I think that this is a general remark that some users make about Wicket. >> It >> is very difficult to reuse part of the code. >> >> Here is another example : >> >> I have a label called id which is used in different page. The way >> proposes >> by Wicket to code it is >> >> Page Request >> >> item.add(new Label("id", String.valueOf(request.getId()))); >> >> Page Notification >> >> item.add(new Label("id", String.valueOf(notification.getId()))); >> >> When we compare page request and page notification, we see that we repeat >> the same code two times. > Hi > > I think the "wicket way" here may be to create a panel containing this > label and then reuse the panel. The panel could also have a model in > order to get the label content. > > Would this solve your repetition issue ? > > ++ > joseph > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > For additional commands, e-mail: users-h...@wicket.apache.org > > > ----- Charles Moulliard SOA Architect My Blog : http://cmoulliard.blogspot.com/ http://cmoulliard.blogspot.com/ -- View this message in context: http://www.nabble.com/Is-it-the-best-way-to-code-a-Link-depending-on-a-condition-tp25488603p25504977.html Sent from the Wicket - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org