Reloading pages in Wicket

Posted on August 7, 2009. Filed under: Java | Tags: , , , |

When developing software, and especially web frontends, is nice and handy to get some immediate feedback on the work you’ve done, without having to rebuild all dependent projects, killing servers, redeploying wars, etc.

At my current project, we have a simple web frontend which is using Wicket, which needs some changes now and then. Unfortunately, Wicket doesn’t reload pages out of the box, and you need some to make this work.

What is recommended to do (but not required), is to set Wicket in development mode. This can be done in multiple ways, but I’ve set the System property ‘wicket.configuration’ to ‘development’. Then, by changing some code in the WicketApplication (which extends WebApplication), you can enable the hot reloading of resource files. The following code is required for that:

String configurationType = getConfigurationType();
if (DEVELOPMENT.equalsIgnoreCase(configurationType)) {
  log.info("You are in DEVELOPMENT mode");  
  getResourceSettings().setResourcePollFrequency(Duration.ONE_SECOND);
}

This way, by recompiling the classes, Wicket detects the changes to HTML and will reload them for you, without having to redeploy the whole application, or needing to restart Jetty. Nice!

References

Wicket FAQ

Advertisements

Make a Comment

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

One Response to “Reloading pages in Wicket”

RSS Feed for Don’t mind the language Comments RSS Feed

Nice one! Been looking for this a long time…


Where's The Comment Form?

Liked it here?
Why not try sites on the blogroll...

%d bloggers like this: