With the Wicket Java Web framework where a lot of magic happens behind the scenes, and almost no XML needs to be configured. Most of it is done with Java. It has a lot of pretty cool features. I just came across this one.

In the init setup of your class that extends WebApplication, you can “mount” your pages at paths, like this:

protected void init() {
	mountBookmarkablePage("/search", SearchPage.class);

So when you goto http://somewhere.com/somecontext/search, it gives you the SearchPage class.

You can also specify a HomePage index, like this:

public Class getHomePage() {
	return IndexPage.class;

Then when you goto http://somewhere.com/somecontext/, it gives you the IndexPage class.

The cool subtle thing here is what happens when you do them both; i.e. you mount SearchPage to /search, and you override getHomePage to return SearchPage.class. Do this, and when you goto http://somewhere.com/somecontext/, it will redirect to http://somewhere.com/somecontext/search!

Leave a reply


<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>