Wicket continues to impress me

11 12 2008

So I wanted to put in a conditional css thing to fix a IE problem, todo this thing in wicket I just though up a way. And wrote the code, it just worked:)

Heres how:
Markup (in head):

<style wicket:id="ieStyle" type="text/css">


A simple webmarkupcontainer, to put in the hack (with a resource reference)::

add(new WebMarkupContainer("ieStyle"){

protected void onComponentTagBody(MarkupStream markupStream,
ComponentTag openTag) {
super.onComponentTagBody(markupStream, openTag);
String csshoverurl=urlFor(new ResourceReference(BasePage.class,"csshover2.htc")).toString();
getResponse().write("" +
"body {" +
"behavior: url("+csshoverurl+");" +



And to finish it up make it conditional so only IE picks it up, by adding a behavior:

public class IECheckBehaviorBehavior extends  AbstractBehavior {
public IECheckBehaviorBehavior() {
public void beforeRender(Component component) {
Response response = component.getResponse();
response.write("*!--[if lt IE 7]&gt;--*");
public void onRendered(Component component) {
Response response = component.getResponse();

The result:

<!--[if lt IE 7]&gt;-->
body {behavior: url(resources/zeuzgroup.web.page.BasePage/csshover2.htc;jsessionid=1pjzdpc4j8asn);}

Simple and and almost clean 🙂

Ps updated the post to show correct source




7 responses

11 12 2008

i think there is a little display problem with the “Markup (in head)” block.

11 12 2008

Yepp “almost” clean 😉

You could also make the whole thing conditional on the server side, IE check if the User-Agent is lower than IE7 and make the HeaderContribution then, or am I missing something?

11 12 2008

@2: No youre completely correct it’s two different styles of it.

My approach does less less on the server side, and only lets IE pickup the hack, although the code will still be there for firefox to ignore…

But my main point where that something that I thought would be hard todo in wicket, where just very easy 🙂

11 12 2008

oops, i didn’t see the ps 😡

11 12 2008

@3 : hehe no problem.

8 04 2009

u mean *ceases* to impress u rite?

10 04 2009

No I mean, that it continues to impress me, by being simple and straight forward:)

Hehe I realize that I made a spelling error 🙂

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: