This Confluence has been LDAP enabled, if you are an ASF Committer, please use your LDAP Credentials to login. Any problems file an INFRA jira ticket please.

Child pages
  • How to remove wicket markup from output
Skip to end of metadata
Go to start of metadata


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 means 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.

Change to deployment mode

The simplest way to remove all wicket tags is to simply change your application from development mode to deployment mode. In your web.xml file, the following sets your application into development mode, which includes all wicket tags and provides an AJAX debugger.


The following sets your application into deployment mode, which removes all wicket tags.  It also removes the AJAX debugger.


See the Deployment FAQ for more details.

Strip Wicket tags in development mode

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 always 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.

Remove wicket markup from a single page

In some situations during development, there may be some pages that should not include wicket tags in the output, but it is desired to have wicket tags on the remaining pages.  For instance, when creating a well formed XML document from Wicket, extra wicket tags and attribute markup can cause problems. One solution is to add the following to the page:

private boolean stripTags;

public TestPage() {
	stripTags =  Application.get().getMarkupSettings().getStripWicketTags();
protected void onBeforeRender() {
protected void onAfterRender() {
  • No labels