Igor Vaynberg is wellknown in the Apache Wicket Developer scene, since he is a core developer of this framework. From Packt Publishing I have got his new book with the title Apache Wicket Cookbook. I was very exited to get it. As some of my blog readers know I have evaluated Wicket in the past and finally moved on to Struts 2. Reason was, documentation is really worse and the highly complex code you need to write for trivial sometimes. Some people still claim Wicket development is easy, but I say it’s not. In my expectation Igors book will answer several questions I could not solve so far. Apache Wicket Cookbook covers version 1.4.x of Wicket. For the upcoming version 1.5.x you can expect some changes. Wicket does not care much about backward compatibility when increasing the middle number.
You’ll need to have learned some basics in Wicket before this book is of help.
The table of content holds what the title promises: this book is a real cookbook. Every chapter contain several articles in the style of How-Tos. It’s really a joy to read through them. Structure is always the same: use case, preparations, problem solving, explain, pitfalls/comments and reference. A big plus for readability.
The topics of the book are Validation, AJAX, Forms, Localization, some displaying stuff, charts and security. Most common problems are covered. A chapter with Wicket design patterns is even available online. Even integration with Middleware is covered. But clearly Spring, Dependency Injection and JPA has no focus. Wicket is a frontend framework and on nearly 260 pages out of 290 cover frontend development.
Lucky me, while Wicket does not following coding conventions by Sunracle, this book does. Thanks.
Another very good thing is, Igor doesn’t try to be a Edgar Allen Poe. No clutter. Just the facts. That’s good. For a cookbook, which should be on your desk while you work, it is pain to read the same joke for 10 times. Instead of joking, Igor simply explains what’s going on. No Clutter and no mess - again a big plus. Wasn’t it Hermann Hesse, who said an author must delete everything from his writing which is not important? Igor has made that very well.
When I read through the Captcha example, I Igor referenced the wicket-extension package. From there I took the captcha classes myself, long time ago. It was the first time I could have made use of this book in old times.
I have managed it to work it out for my application in a pretty fine time. This was the first time I really could have used Igors book. It’s not witchery what he describes here, but its pretty helpful to get the right pointers and an explain. It saves time. I would have expected text like that in the Wicket documentation, to be honest. From chapter to chapter the Apache Wicket Cookbook feels more like the “missing manual”. That being said, the Validation and Form chapters take already roundabout 70 pages. I have not found a question which is unanswered. No surprises if you have made it before, but sometimes you simply forget and then this book come to save you.
Similar experiences with the chapter of localization. Nothing new - localization is even fine in the docs. But sometimes you find some gems, like how you can debug resource loading. This was very helpful.
Very good was the DataTable chapter. There were some stuff inside which I have not explored yet. While I showed my Data already in the DataTable, i have not sorted it. It was very easy to see how it works - Igor did it with a plain Comparator. Guess this is, what people mean, when they say “Wicket is easy”. But hey, look for yourself. There is a sample chapter online.
Later I checked out the AJAX chapter which was the most awaited part of this book. Igor showed how to add behaviors to Buttons or InputFields (it’s like Swing, if you ask me). I already have explored that in Wicket, but it was very good to see my thoughts were not too wrong. I must admit, even when I have made my stuff very similar, I have learned from this chapter. New to me was the “blocking ajax requests on complete”. This should prevent multiple clicks on the Ajax causing element. It showed me, how I can return some JavaScript form a Decorator. I hate it. Not the book of course, but this is part were I start to hate Wicket. Anyway, it’s another story. Thanks to Igor I could understand this scenery better. I already have guessed it should work this way. After all I have learned how to do basic things with AJAX. If you want to return plain JSON - read on to the Chart chapter. Sad, there was no reference from the AJAX chapter. I would have expected a pure “return your JSON” example in the AJAX chapter. With hiding it into the Charts chapter this important knowledge is a bit of a side dish.
But how can I make use of jQuery? After reading the whole AJAX chapter (and the charts) I have the chance to work it out myself, somehow. But an example would have been nice and jQuery (or whatever) is an often used lib. The whole Web 2.0 stuff is so important, I would have loved more examples - compared to the Validation/Form chapter it feels a bit incomplete.
Later we leave a bit the world of hardcore JavaScript and enter Rich UIs. Interesting indeed, because you cannot find this examples easily. Again we are heading on to Forms and let them update dynamically. Day to day work, explained step by step. Very interesting here is the PortalLayout which lets you create some kind of dashboard with movable widgets. This is pretty cool stuff and I haven’t seen something like this in the Wicket world before. It is a pretty long and detailed example - after that you are a true Wicket user.
Security chapter explains authentication to you. It seems to be based on the examples again. My login components look very similar. Igor even explained how to secure pages with Annotations, which I actually did prior the book. This is a real life example. Very cool is the OpenID example. That’s really fantastic. Igor also explains a bit on the RequestCycle - but I would like to read more on that. The RequestCycle is critical for Wicket. Understanding it helps you to deal out with many problems, imho.
The middleware chapter and shows you how you can implement your database. It’s pretty short, but you can make your steps. Even when you use tools like Apache Cayenne, you can benefit from this chapter. Anyway, it’s clearly not the focus of the book adn that’s OK.
So after reading, what is the Outcome?
Conclusion
Igor wrote an excellent book. It’s good to read and perfect to understand. Standard tasks are all explained very well. If you want to build up an application from scratch, here you go: for nearly each task you can find a solution. A bit more pain you will feel when you leave the standard path.
For example, would you like to learn how you organize your tons of JavaScript the best way? How would you work with ready-to-use JavaScript components? How to interact with jQuery?
I have a few more questions I would like to see in this book: How can I create simple configuration files? Wicket is not offering anything - but how do Wicket Pros solve this?
I would also like to learn how to extend the RequestCycle itself. In the Security chapter there is a bit stuff in that direction, but it would be cool to learn more. But the subtitle of this book is about solving common problems. Probably this is not common enough.
How do I organize my Wicket application? This is more a global topic, I know, but still important. Should I separate my HTML files to another folder than my class files? How to organize my component packages? When to use panel, when not? And so on.
Anyway - this book is excellent. If you work with Wicket, you need a copy. You have simply better chances to work things out if you have it on your desk. If you are a beginner Wicket Developer, then you should first play a bit around with the docs and do some basic stuff before you solve your problems with the Apache Wicket Cookbook.
I really hope Igor will write a new version with more examples when Wicket 1.5 is out. And hopefully he adds some more answers oto my questions. Thumbs up, well done.
Tags: #Apache Wicket