Wicket in Action

A comprehensive guide for Java developers building Wicket-based web applications

Validating your markup on the fly

One of the most puzzling things about web development is when something works in one browser, but doesn’t in another. Often this is the case when your document is not standards compliant. For example you declare that your markup is XHTML strict, but have a structural problem in your markup. Browsers will try to repair your document, but can take different measures to cope with the problem.

The way to avoid such differences is to ensure that at least your documents are up to spec. Running your website manually through the W3C validator is not an option. So I set out to make this a less painful exercise. Searching the internets provided me with the Tuckey ValidationFilter, but integrating it with our application was not really working, because of some CSS issues (z-index, fonts, alignment, coloring). Long story short, I’d figure taking up the ValidationFilter and integrating it someway into a little bit more Wicket like fashion. I’ve implemented it as a IResponseFilter and have it insert the necessary markup into the response at the end of the head and body sections when the original markup was invalid.

When you enable the HtmlValidatorResponseFilter in your project, you see your markup mistakes immediately when developing your application. No longer is standards compliant markup an afterthought, but directly visible the moment you fire up your local server and browser.

The htmlvalidator project contains an example application with valid and invalid markup. You can run it by starting the embedded Jetty server using the Start class in the src/test/java folder and pointing your browser to localhost:8080.

The project is available on my github space. The project needs to be build using Maven, but that shouldn’t hold you back trying it out. It mostly builds upon the code from the Tuckey guys, so major thanks go to them. I’m hoping to find an Apache License compatible, up to date, markup validator so we can ship this functionality out of the box with Wicket 1.5.

Things I’d like to improve:

  • no more GPL code
  • use Wicket components instead of a generated JSP for the error page
  • integrate it into a debug console together with Ajax debug, ehcache stats, hibernate stats, page stats, wicket stats, etc.

With this book, Wicket will become the greatest territory the Dutch have settled since Manhattan.

Nathan Hamblen
Senior Software Engineer, Teachscape Inc.

This is the complete and authoritative guide to Wicket, written and reviewed by the core members of the Apache Wicket team. If there's anything you want to know about Wicket, you are sure to find it in this book.

Jonathan Locke
Founder and Architect of Apache Wicket, Foreword Wicket in Action

Without question, Wicket in Action... is the be-all and end-all when it comes to Wicket.

Geertjan Wielenga, Wicket Netbeans Plugin Author

The tutorial and conversational tone of the writing makes the book very approachable.

Nick Heudecker
System Mobile

Loved the sample application—it tied everything together.

Phil Hanna
Senior Software Developer, SAS Institute

The essential guide for learning and using Wicket.

Erik van Oosten
Lead programmer and Project Manager, JTeam

Finally, the Web Framework of web frameworks, Apache Wicket, now has a bible of its own.

Per Ejeklint
Senior Software Architect, Heimore group

Wicket is an innovative evolution of the MVC programming with simple roots, but without a primer such as this, it can be more challenging than it needs to be.

Brian Topping
Founder, Bill2 Inc.

Wicket In Action glues the areas of web development with Apache Wicket together and gives a great overview of Apache Wicket...it will make a great compendium.

Nino Martinez Wael
Java Specialist, Jayway Denmark