I'm trying to find out ways to reduce boilerplate code when toggling
visibility of regions
of a page using ajax calls. Basically i'd like to extend wicket:enclosure to
overcome this limitation:
"Changing the visibility of a child component in Ajax callback method
will not affect the entire
enclosure but just the child component itself. This is because only the
child component is added
to the AjaxRequestTarget."
I'd like to use wicket:enclosure as an inline attribute (without needing a
separate placeholder tag).
So instead of this:
<wicket:enclosure child="toggleable-placeholder:toggleable">
<tr wicket:id="toggleable-placeholder" bgcolor="red">
...
I'd like to write like this:
<tr wicket:enclosure="child:toggleable" bgcolor="red">
<!-- The element 'toggleable' would determine visibility of the whole
enclosure -->
<td>
<input wicket:id="toggleable" type="button"
wicket:message="value:toggleable"
style="border: 1px solid black; background:
lightblue;" />
Also this part should toggle
</td>
</tr>
I'd also like to reduce code needed for this on java side, so that the above
could be matched with
something like this:
add((toggleable = new
WebMarkupContainer("toggleable")).setOutputMarkupPlaceholderTag(true));
Now, a suitable ajax event (like clicking a button), would simply toggle the
visibility of the
component 'toggleable', thus triggering the visibility change for the
enclosure as well.
I've been reading the existing wicket code base but have more questions than
answers..
Any ideas on how to best proceed with this?