Joshua Java

My first impression about Wicket

Posted on: November 12, 2007

So I went searching for another web framework that fits into the company’s app server infrastructure. The company uses an IBM Websphere AS 5.1 which still uses Servlet 2.3 spec. Wicket is one of Java web framework that works on JDK 1.4 and Servlet 2.3, it just works nicely (with some configuration).

I feel that the advertisement saying that Wicket can increase your productivity is not a talk only. It really boost up your development productivity. Why? Because everything from the configuration to component structuring is done in Java which leads to a strong typing. The exception during runtime is also very informative.

IMO Wicket is a different kinda framework among other framework because besides it teaches you to create a clean web page design, it also teaches you a good OOP design. Everything regarding the web component structuring is done in Java which looks more like Swing programming. Some people don’t like this (I feel the same way too the first time I read the doc), but once you get feel of it, the ‘Wicket way’ is quite fun.

This is the kinda Java programming you would do with Wicket to get the idea of it:

public class DepartmentInput extends BasePage{
	public DepartmentInput() {
		add( new DepartmentInputForm("departmentInputForm",
			new CompoundPropertyModel(new Department())));

		add( new Label("departmentName",
			new PropertyModel(department, "name" ) ));
	}

	public class DepartmentInputForm extends Form{
		public DepartmentInputForm(String id,
				final CompoundPropertyModel model) {

			super(id, model);
			department = (Department)model.getObject();
			add(new TextField( "name" ));
			add(new Button("save"){
				public void onSubmit(){
					getDepartmentService().save(department);
				}
			});
		}
	}
}

The Java code for structuring is nested just like the html code. So you will most likely create lots of inner class and extend other Page component class. You will also find lots of final mark because you want to call an instance from an inner class.
The HTML template is very clean as there is no programming at all in it and only functions as a template, this makes Java as the first class citizen in Wicket webapps. The template really helps web designer since it doesn’t introduce any new tag and doesn’t require to be run on a servlet container and web designer can open it on their favorite HTML editor and it also acts as a page mock for the developer.
Here’s wicket template to get the idea of it:

<html>
<head></head>
 <body>
 	<form wicket:id="departmentInputForm">
 		<input type="text" wicket:id="name"/>
 		<input type="submit" wicket:id="save" />
 	</form>
 	<span wicket:id="departmentName">Marketing</span>
 </body>
</html>

This approach for view layer is very important in a case where a webdesigner doesn’t understand JSP & servlet container at all. Having been into this kind of situation, IMHO Wicket is very excellent because it enables the programming team and the web designer to work in parralel simultaneously.The best of all, I really like the paging component in wicket as I’ve found nothing is better/easier than wicket’s paging component.The drawbacks about Wicket that I’ve found so far which most developer complaint about is:

  1. Wicket is too slow because it keeps the whole Page component tree into memory. But wicket’s developer defend that memory nowadays is cheap.
  2. And the docs from the wiki are somehow outdated and some doesn’t even work. But this would not be a problem since the community in the mailing lists are very helpful and most likely you will get answers from the committers directly.

All in all Wicket is a very interesting framework as it is not just another Java web framework. But you have to try it first to prove my words.

4 Responses to "My first impression about Wicket"

Too slow would not be accurate. Wicket is extremely fast. As fast as the fastest web frameworks out there. What you meant to say is that people have concerns about scalability. I can tell you from experience that you do need to keep an eye on memory and network use, but if you design and implement reasonably, this is really not an issue. The documentation issues are par for the course in open source. Luckily there will be a second book out on Wicket soon “Wicket in Action”. That should help some.

Thanks for stopping by Jonathan. Though wicket still lack in documentation, I still praise on the JavaDoc which is very concise.🙂

Little nuance – with JSF + Facelets (and I believe also Tapestry), the HTML is separated from the code so that the page designer and programmer can work separately. However, in JSF, the programmer will have to edit the HTML to associate the appropriate event handlers. In Wicket, he does the association in code. In other words, Wicket separates the page designer and the programmer even in terms of the files they handle(!)

3 years have gone now, but I am learning the Wicket framework now and about the issue of resources and scalability, Wicket has a Detachable model which lets you get rid of serializable model components, so it should be quite lean.

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

%d bloggers like this: