technology from back to front

Wicket

I recently used wicket to knock up a simple web shop example for our ExproRetail product and found it to be a fairly pleasant experience.

Wicket is (yet another) Java web framework but it distinguishes itself from many others with the following features:

  • No XML configuration
  • Very clean page templates
  • High level of abstraction – User code rarely has to refer to HTTP concepts

Writing a Wicket app is rather more like writing an event-based desktop application than a web application. For example, to render a link and react when it’s clicked all that’s needed is:

In the template:

<a wicket:id="mylink">Click me</a>

In the code:

add(new Link("mylink") {
  public void onClick() {
    // Do something when link clicked...
  }
});

Similarly, to handle a form submission you could create a TextField, give it a model to read/write its data to and add it to a Form. In either case there is no need to worry about constructing specific URLs, query parameters, HTML escaping etc.

Templates are just standard XHTML with a sprinkling of wicket attributes. When Wicket renders the template and encounters a wicket:id it looks for a matching component to render the tagged element. This is a simple and powerful system very similar to that used by the Python web kit nevow.

Wicket also makes it very easy to create custom “widgets”: Simply extend from an appropriate subclass of Component and provide a snippet of XHTML (if needed). To use your widget, all that’s needed is a simple add(new YourComponent(...)).

With version 1.2 there’s lots of AJAXy goodness too but I’ve yet to try this myself and the docs seem to be slipping behind a little.

The downside to all this convenience, at least for any reasonably busy site, is that Wicket stores a lot of state in user sessions. Some of the time gained letting Wicket manage everything may be lost ensuring that session usage is kept under control.

by
mporter
on
06/07/06
  1. Glad you like Wicket. But I’m curious what you’ve needed to do in terms of controlling session usage and why. Are you clustering Wicket? What was your decision process to tune Wicket versus buying more RAM or boxes?

  2. I’ll go for wicket for the next web application project. I’ve use Tapestry 5 before. ANd I think Wicket very tempting to try…

 
 


+ 9 = eleven

2000-14 LShift Ltd, 1st Floor, Hoxton Point, 6 Rufus Street, London, N1 6PE, UK+44 (0)20 7729 7060   Contact us