An Enclosure are automatically created by Wicket. Do not create it yourself. An Enclosure container is created if <wicket:enclosure> is found in the markup. It is meant to solve the following situation. Instead of
<table wicket:id="label-container" class="notify"><tr><td><span wicket:id="label">[[notification]]</span></td></tr></table> WebMarkupContainer container=new WebMarkupContainer("label-container") { public boolean isVisible() { return hasNotification(); } }; add(container); container.add(new Label("label", notificationModel));
with Enclosure you are able to do the following:
<wicket:enclosure> <table class="notify"><tr><td><span wicket:id="label">[[notification]]</span></td></tr></table> </wicket:enclosure> add(new Label("label", notificationModel)) { public boolean isVisible() { return hasNotification(); } }
Please note that since a transparent auto-component is created for the tag, the markup and the component hierarchy will not be in sync which leads to subtle differences if your code relies on onBeforeRender() and validate() being called for the children inside the enclosure tag. E.g. it might happen that onBeforeRender() and validate() gets called on invisible components. In doubt, please fall back to {@link EnclosureContainer}.
Additionally due to the reason above it is not possible to assert that children in Enclosure are not visible to WicketTester.
@see EnclosureHandler
@see EnclosureContainer
@author igor
@author Juergen Donnerstag
@since 1.3