Thursday, April 05, 2007

How to localise an image with Wicket

The simplest way to localise an image with Wicket:
In the HTML, e.g. com/myco/MyPage.html:
<img src="myimg.gif" wicket:id="myid" />

In the Java code, e.g.
add(new Image("myid"));

Then Wicket will look for the image myimg_en_US.gif in the com/myco/ directory.

1 comment:

Eelco Hillenius said...

Funny, I wasn't even aware of that. I always used add(new Image("myid", new ResourceReference("myimg.gif"));

Another way:

  <img src="myimg.gif" />

You can nest an arbitrary number of links and images between <wicket:link> tags, and you don't even have to explicitly add components in Java.