interesting idea. i think this would require a bit of a trick.

a) modify enclosure tag handler to accept an attribute instead of a tag
b) modify enclosure tag handler to add a bit of metadata to the
component marking that it belongs to an enclosure
c) add a ajaxrequesttarget.listener to the request target that checks
for this bit of metadata and adds the enclosure container to the ajax
request target.

not sure how feasible this all is because the enclosure container is
an auto component. but, you are welcome to tinker around.

-igor

On Thu, Jan 20, 2011 at 6:25 AM, Joo Hama <[email protected]> wrote:
> 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?
>

Reply via email to