Working with REAL Java Objects

Tutorial - Apache Wicket: The Fun Web Framework - Part 4


Top 10 Things Every Wicket Programmer Should Know

 This is a condensed version of my list of the top ten things that every Wicket programmer should know. For the complete version, see

  1. Models – Really make sure that you understand models before writing any large application in Wicket.
  2. Pull, don't push – In general, your components should be able to pull their state rather than having some other component push the state on it. The example below demonstrates what this means and why it's important. The key is that the constructor only runs once, but many things on the page might change state after the constructor is run. If you push your state into components in your constructor, they are out-of-date as soon as another component changes state. The only alternative is that every component must know about all other components that share state – and that's not “the Wicket way”. Your components should be independent and reusable.
  3. Wicket is a UI framework – Don't write middle tier or persistence code in Wicket.
  4. Keep markup and code clean and compact – Become familiar with and use the various aspects of Wicket that allow for reusability – panels, markup inheritance, and fragments as examples.
  5. Match your hierarchies – It won't take you long at all to learn this rule, but the hierarchy of components in your markup (tags with a wicket:id attribute) must match the hierarchy in your Java code.
  6. Form processing lifecycle – When dealing with forms, it is important to understand the order of operations of the form post processing. If any step in the process fails the onError method of your form and submitting button will be called rather than the onSubmit method (picture below)
  7. Java nuances – There are two Java nuances that catch many Wicket newcomers off-guard – serialization and the presence of anonymous inner classes. Become more familiar with both.
  8. Unit testing – Testing your Wicket code is made relatively easy by using WicketTester. Try it out.
  9. i18n – Internationalization is made very easy with Wicket. Become familiar with things like wicket:message and file naming standards for Wicket's built-in i18n support.
  10. Where to find help – Wicket code is well documented, so reading JavaDocs is a good start. Wicket examples can be viewed online at GitHub. Additionally, Wicket has one of busiest and most helpful mailing lists of any open source project. For more information on the Wicket mailing lists, see


I chose Apache Wicket because other frameworks sucked the fun out of web programming (okay, this is subjective, but I can say that I didn't personally enjoy them). Most of my time seemed to be spent dealing with pushing state around or writing configuration in XML. Every little change required changes in multiple files – many times in XML, Java, and specialized markup files. It was hard to make cohesive reusable components. A few days with Wicket made me see how drastically different it was. I was writing real Java object-oriented code, and easily creating reusable components. I hope that you will give it a few days for your own project or experiment so that you, too can discover how much fun web programming can be.

For more information on Wicket, see

Jeremy Thomerson is a technology enthusiast who loves exploring, learning, and creating new technologies. He has helped numerous companies upgrade their architectures to multi-tier architectures primarily based on the leading Java open source technologies, including Wicket, Spring, Lucene, Hibernate and more. For the past several years, he has owned and operated the leading U.S. company providing Wicket training and consulting services.

This article originally appeared in Java Tech Journal - Java Web Frameworks. You'll find more of that issue here for download.


Jeremy Thomerson
Jeremy Thomerson

What do you think?

JAX Magazine - 2014 - 06 Exclucively for iPad users JAX Magazine on Android


Latest opinions