Monday, June 29, 2009

CSS load order with Wicket and an external jar

I had a problem with the CSS from a provided jar (wicketstuff-jquery) overriding my local CSS. To get around this, I made sure the jar's CSS loaded first:

add(CSSPackageResource.getHeaderContribution(JQTabbedPanel.class, "jquery.tabs.css"));
add(CSSPackageResource.getHeaderContribution(MyWicketPage.class, "MyWicketPage.css"));

Wicket is clever enough to not load the same CSS twice. I knew which class and CSS file load by looking at the generated source:
<link rel="stylesheet" type="text/css" href="resources/org.wicketstuff.jquery.tabs.JQTabbedPanel/jquery.tabs.css" />