You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

All relevant Wicket tags and attributes must be in the wicket namespace, wicket:id="myLabel" or <wicket:panel>. Most browsers simply ignore HTML tags and attributes they don't know, which is why it doesn't harm that Wicket by default copies information into the HTML output generated. And it comes handy while tracing bugs.

However for the output to be HTML compliant, there must be a mean to remove Wicket specific information not relevant for the client browser from markup. XHTML shouldn't be a problem because all wicket-specific information is cleanly separated by using the wicket namespace, but not all browsers support XHTML well enough not to stumble over them.

The solution is to call getMarkupSettings().setStripWicketTags(true) in the init method of your Application class. (Use getSettings().setStripWicketTags(true) for Wicket 1.1 and earlier.) This will remove from output all Wicket tags with Wicket namespace. That is, your output should not contain any tag like <wicket:panel> any more. It is off by default (not removing the tag). As these tags are not relevant for the client browser at all, I'd allways keep it off during development and switch it on (remove them) for production sites.

In some cases you do not want the component's html to be wrapped by a div or span. In that case include a {{

<span wicket:id="myLabel">

}} as usual, but in java call setRenderBodyOnly(true) on the component. The span will be omitted from the output.

  • No labels