Wicket in Action

Header contributions positioning

14 March 2014, by martin-g

Wicket 6.0.0 came with some nice improvements in the header contribution management.

With these improvements it is possible to put a specific header contribution at the top of all others by using PriorityHeaderItem, or to group several header contributions in a specific spot in the page body by using FilteredHeaderItem, but still it was quite hard to something simple like making sure that <meta charset="utf-8"/> is always the very first item in the page <head>.

<wicket:header-items/>

With WICKET-5531 (since Wicket 6.15.0) we added one more facility that should make header contributions management even more flexible.

By using markup like the one below in YourPage.html

<head>
  <meta chartset="UTF-8"/>
  <wicket:header-items/>
  <script src="my-monkey-patch-of-wicket-ajax.js"></script>
</head>

all header contributions done by using IHeaderResponse in your Java code or the special wicket:head tag will be put between the <meta> and <script> elements, i.e. in the place of <wicket:header-items/>.

This way you can make sure that some header item is always before or after the header items managed by Wicket.

<wicket:header-items/> can be used only in the page's <head> element and there could be at most one instance of it.

-->