You already have seen some Wicket components in action. You also learned that you can influence what the components actually do by providing them with proper models. Now it is time to look at how to customize Wicket components.
Usually you do not want to start from scratch when you customize a component. Most components can be extended, and have methods that are explicitly meant for customization.
Some components do not even work without this, like
wicket.markup.html.link.Link, which has abstract method
wicket.markup.html.list.ListView that has abstract method
wicket.markup.html.form.DropDownChoice is a non-abstract component, but by extending it, we can alter its behaviour. For example, look at:
By overloading method
wantOnSelectionChangedNotifications(), and have it return
true (instead of
And if we want to customize the component even further, we could do:
and do something nice in the
onSelectionChanged() event handler.
By making use of models that use e.g. a shared property, we can do all kinds of neat things. Here is an example:
Note that we fed our dropdown with a property model that works on
this (e.g. a Page) using property 'currentVenue'. Now, with the second component we override method
isVisible, and use that same property 'currentVenue' for our evaluation.
If any venue is selected, we'll display the container and anything that is nested on it. If no venue is selected, we do not display anything. This is a very handy trick to switch parts of your page on and off, and as the dropdown will generate a roundtrip on each selection, our page will feel very dynamic.
TODO... write more
Panels and Borders
See also Panels and borders to see the difference between Panels and Borders.
Both Panels and Borders have their own markup file, but the markup is used in different ways:
The Border component inserts markup before and after its child components.
The Panel component inserts markup into the body of the tag.
See Panel for more information.
Doing it (almost) from scratch