Class EnclosureContainer

All Implemented Interfaces:
Serializable, Iterable<Component>, IEventSink, IEventSource, IFeedbackContributor, IConverterLocator, IMetadataContext<Serializable,Component>, IHeaderContributor, IRequestableComponent, IHierarchical<Component>, IClusterable

<wicket:enclosure> is nice and prevents that users have to add boilerplate to their application. But it is not without problems. The child components are children in the markup, but the auto-component generated for the enclosure tag will not magically re-parent the child components. Thus, the markup hierarchy and the component hierarchy will be out of sync. The automatically created enclosure container will be created alongside its "children" with both attached to the very same parent container. That leads to a tricky situation since e.g. onBeforeRender() will be called for enclosure children even if the enclosure is made invisible by it controlling child.

On top auto-components cannot keep any state. A new instance is created during each render process and automatically deleted at the end. That implies that we cannot prevent validation() from being called, since validation() is called before the actual render process has started.

Where any of these problems apply, you may replace the tag and manually add this simple container which basically does the same. But instead of adding the children to the Page, Panel whatever, you must add the children to this container in order to keep the component hierarchy in sync.

Note: Make sure the markup element associated with this EnclosureContainer is anything but <wicket:enclosure>, e.g. a <div>, a <span> or even a <wicket:container>

Juergen Donnerstag
See Also: