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
Read Full Post | Make a Comment ( 1 so far )

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