Wicket in Action

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

Implement Wicket component visibility changes properly

Igor mentioned this in a thread on our user mailing list on how to properly implement component visibility changes. I figured that this demanded a greater audience so I took the liberty of republishing his thoughts here.

If the component itself controls its own visibility the best way is to override onConfigure() and call setVisible() inside.

If an outside component controls another’s visibility the best way is to override the controlling component’s onConfigure() and call controlled.setVisible()

If you have a simple state toggle, like “when i click this link i want this component’s visibility to change” then calling component.setVisible() is fine.

If you have a cross-cutting concern (authorization strategy, configure listener, before render listener, etc) overriding component’s visibility then call component.setVisibilityAllowed(). Wicket ands this bit with the visible bit to determine final visibility; this way the cross-cutting concern won’t dirty component’s visibility attribute.

If all of these fail, as a last resort override component.isVisible() but be warned that this has a few pitfalls:

  • it is called multiple times per request, potentially tens of times, so keep the implementation computationally light
  • this value should remain stable across the render/respond boundary. Meaning if isVisible() returns true when rendering a button, but when the button is clicked returns false you will get an error

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