Wicket : provide a body to your tags !
Hi
We had a strange issue here : we created a component opened for extension. For some reason it was working with a Label but not a MultilineLabel. Crazy isn’t it ?
It turned out we declare this “opened” component like this :
The user of it should just override a callback method like this :
| Java | | copy | | ? |
@Override |
protected Component createContentComponent(final String id, final IModel model) |
{ |
return new MultiLineLabel(id, model.getObject().getContent()); |
} |
So why wasn’t it working ?
Simple : MultilineLabel uses replaceComponentTagBody(markupStream, openTag, body);
Or my container didn’t have any body :
Simply switching to this solved the issue :
Conclusion : always provide a body for your components, you don’t know what’ll be done with them !
++


uwe recently informed me that it was in fact already told so in wicket wiki “Best practices and Gotchas” page (the last one). Thanks !