Search code examples
templateswicketpanelwicket-1.5webpage-rendering

Wicket: Is it possible to display components of a panel based on page the panel is added to?


I'm pretty new to Wicket, so please excuse me if this is a simple task. I tried to look for examples but came up empty.

Here's the scenario. Lets say that I have a customer information panel with 25 data points (name, dob, address, phone, etc). I want to reuse this panel in many different pages on a site. Now lets say I have the following criteria on 3 different pages the panel appears on:

  • Page 1 - All fields are visible and editable
  • Page 2 - Date of Birth, Gender, Customer Name are visible but not editable, all other fields are visible and editable
  • Page 3 - Date of Birth and Gender are not visible, Address is visible and editable, all other fields are visible but not editable.

Is there a way to use the same panel (to reduce code duplication), but control its components based on the current page the panel is loaded into?

Thanks for any help!


Solution

  • I would suggest against changing the visibility and editability implicitly like this. Instead consider making it explicit based on constructor arguments for the component or additional methods on the custom component.