wicket-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pierre Goiffon <Pierre.Goif...@interview-efm.com>
Subject Re: renderHead() / wicket:head page / component order
Date Tue, 10 Jul 2012 09:18:39 GMT
 >> We recently upgrade to Wicket 1.5. One of the major concern during that
 >> migration was to deal with the new order of the header render strategy.
 >> I see this is defined in AbstractHeaderRenderStrategy#get()
 >> For exemple I am just dealing with a problem in a page hierarchy like
 >> the one below :
 >> pageA : adds mycss.css using renderHead and a ResourceReference
 >> pageB : adds 6 lines of css to change the behavior in wicket:head
 >> pageC : adds 1 line of css to override a margin in wicket:head

> There are some improvements in this area in Wicket 6.
> Please read http://wicketinaction.com/2012/07/wicket-6-resource-management/
> for more information. Pay attention to PriorityHeaderItem and setting
> custom header item comparator. Header contributions from <wicket:head>
> are represented with org.apache.wicket.markup.head.PageHeaderItem.

Thanks very mutch Martin, very interesting !
Your blog have a lots of very nice posts like this one, I'm going to 
read lots of them really carefully ! I'm very happy to find such a 
resource as documentation is not the strongest Wicket highlight !

Getting back to my concern...

PriorityHeaderItem is a nice answer to serve the most generic resources 
(in my exemple, mycss.css) : clean and simple.
Looking at the Wicket 6 classes in your sample project 
I also see a CssContentHeaderItem that allows to add CSS without adding 
a link and an extra resource to download for the UAs : cool !

But as a developper I still see some issues :
- It's not very convenient to write static css in the Java code instead 
of simply leave it in the html file in a wicket:head block. In prev 1.5 
version it was a very simple way to add static client side code !
- Just using a PriorityHeaderItem wouldn't be enough, cause I need the 
header contribution to be in the order A / B / C. I would need to write 
a custom comparator... And it wouldn't be that nice because in my case 
page A and page B are in a different project than page C - this latter 
is the only one to be in the same project as the wicket application 
class. The custom comparator would also certainly become quite unusable, 
dealing with too many specific cases ?

For the 1.5 branch a simple solution I see would be to let the 
IHeaderRenderStrategy be defined by the Wicket application class. So 
every one would be able to choose what is his most wanted preference : 
be able to override parent renderHead() methods 
(ChildFirstHeaderRenderStrategy), or have a very simple mean to insert 
cascading client side static code (ParentFirstHeaderRenderStrategy).

I you use a ParentFirstHeaderRenderStrategy and still need to override a 
parent renderHead() in a specific component, you could still move the 
parent code to an overridable method right ? Like :

parentClass {
	public void renderHeader(..) {

	public void doStuff() {
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org

View raw message