Hi, thanks for the help, I stripped it down to this: (seems to work fine)
public class LabelWithDefaultModel extends Label { public LabelWithDefaultModel(String id, IModel model, IModel defaultModel) { super(id, model); if (this.getModelObject() == null){ this.setModel(defaultModel); } } } 2007/6/14, Martijn Dashorst <[EMAIL PROTECTED]>: > Make it a proper class: > > public class LabelWithDefaultText extends Label { > private String defaultText; > > public LabelWithDefaultText(String id, IModel model, String > defaultText ) { > super(id, model); > this.defaultText = defaultText; > } > @Override > protected void onComponentTagBody(MarkupStream markupStream, > ComponentTag openTag) { > String model = (String) getModelObject(); > replaceComponentTagBody(markupStream, openTag, model == null ? > defaultText : model); > } > }); > } > > Or make a model wrapper > > On 6/14/07, Pieter Cogghe <[EMAIL PROTECTED]> wrote: > > Hi, > > > > I'v got this in a list: > > > > add(new Label("name")) > > > > sometimes there's no name defined, then I want to set a default text, > > I'd do it like this: > > > > add(new Label("name").setDefaultModel(new Model("No name defined"))); > > > > Now I have it like this: > > > > item.add(new Label("name", new PropertyModel(item.getModel(),"name")){ > > @Override > > protected void onComponentTagBody(MarkupStream markupStream, > > ComponentTag openTag) { > > String model = (String) getModelObject(); > > if (model == null){ > > replaceComponentTagBody(markupStream, openTag, "no language > > selected"); > > } else { > > super.onComponentTagBody(markupStream, openTag) > > } > > } > > }); > > > > This is really verbose. Anybody knows a better way? > > > > thanks a lot, > > > > Pieter > > > > > > > > -- > > Pieter Cogghe > > Ganzendries 186 > > 9000 Gent > > 0487 10 14 21 > > > > ------------------------------------------------------------------------- > > This SF.net email is sponsored by DB2 Express > > Download DB2 Express C - the FREE version of DB2 express and take > > control of your XML. No limits. Just data. Click to get it now. > > http://sourceforge.net/powerbar/db2/ > > _______________________________________________ > > Wicket-user mailing list > > Wicket-user@lists.sourceforge.net > > https://lists.sourceforge.net/lists/listinfo/wicket-user > > > > > -- > Join the wicket community at irc.freenode.net: ##wicket > Wicket 1.2.6 contains a very important fix. Download Wicket now! > http://wicketframework.org > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Wicket-user mailing list > Wicket-user@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/wicket-user > -- Pieter Cogghe Ganzendries 186 9000 Gent 0487 10 14 21 ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user