This one is tricky and should be fixed before we release RC5
The way Enclosure works today:
- we always render the <wicket:enclosure>...</wicket:enclosure> tag
- in onComponentBodyTag we check the visibility of the enclosure
child. If visible we continue the render process. If the child is not
visible, than we still render the enclosure but into a NullResponse.
We do that in order to be able to validate that all visible components
were rendered. See the following use case where this is a problem
Page p
p.add(foo)
foo.add(bar)
<wicket:enclosure child="bar"><div wicket:id="foo"><div
wicket:id="bar"></div></div></wicket:enclosure>
with bar.setVisible(false), foo will never be rendered. Without
writing into the NullResponse, Wicket will detect it at the end of the
page render cycle and throw an exception: found (visible) component
but it wasn't rendered.
I did the following change on my laptop:
- sublcass Enclosure.isVisible() with return child.isVisible(). This
has several effects
- <wicket:enclosure> is not written if the child component is not
visible => I could live with it.
- previously enclosure.isVisible() always returned true. IMO it's
obvious that enclosure.isVisible() now returns the child. Because
enclosure is an auto-component and thus added by Wicket, the user will
not know it exists => the change should not affect anybody
- if the enclosure is invisible, the associated markup fragment
will not be iterated, we'll no longer search for the components, no
onBeforeXX and component.render(). This used to be an issue for Forms
and FormComponents => should no longer happen
- it'll simply the enclosure source code
- I changed the code in Page which evaluates the components which
were not rendered. If the unrendered component (foo) has a sibling
that is an IComponentResolver and that component is not visible, than
assume the unrendered component logically belongs there. The process
works recursively to work with multiple levels of IComponentResolvers
(e.g. <wicket:child><wicket:extend><wicket:enclosure> => The
disadvantage is that the check is less strict now. We log a debug
statement though. In my opionion that would be ok.
As you would expect some tests will fail because the output is
different (no more <wicket:enclosure> if the child is invisible).
I'll attach a patch to the jira for you to review. You better test it
against your app.
Juergen