Class Enclosure

  extended by org.apache.wicket.Component
      extended by org.apache.wicket.MarkupContainer
          extended by org.apache.wicket.markup.html.WebMarkupContainer
              extended by org.apache.wicket.markup.html.internal.Enclosure
All Implemented Interfaces:, java.lang.Iterable<Component>, IEventSink, IEventSource, IClusterable, IConverterLocator, IHeaderContributor, IComponentResolver, IRequestableComponent, IHierarchical<Component>
Direct Known Subclasses:

public class Enclosure
extends WebMarkupContainer
implements IComponentResolver

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();
     container.add(new Label("label", notificationModel));
with Enclosure you are able to do the following:
      <table class="notify"><tr><td><span wicket:id="label">[[notification]]</span></td></tr></table>
    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 EnclosureContainer.

Juergen Donnerstag
See Also:
EnclosureResolver, EnclosureHandler, EnclosureContainer, Serialized Form

Field Summary
Fields inherited from class org.apache.wicket.Component
Constructor Summary
Enclosure(java.lang.String id, java.lang.CharSequence childId)
Method Summary
protected  Component getChild()
 java.lang.String getChildId()
protected  MarkupContainer getEnclosureParent()
          Get the real parent container
 boolean isVisible()
          Gets whether this component and any children are visible.
protected  void onInitialize()
          This method is meant to be used as an alternative to initialize components.
 Component resolve(MarkupContainer container, MarkupStream markupStream, ComponentTag tag)
          Try to resolve a component.
Methods inherited from class org.apache.wicket.markup.html.WebMarkupContainer
getWebPage, getWebRequest
Methods inherited from class org.apache.wicket.MarkupContainer
add, addOrReplace, autoAdd, contains, get, get, getAssociatedMarkup, getAssociatedMarkupStream, getMarkup, getMarkupType, hasAssociatedMarkup, internalAdd, internalInitialize, iterator, iterator, onAfterRenderChildren, onComponentTagBody, onMarkupAttached, onRender, remove, remove, removeAll, renderAll, renderAssociatedMarkup, renderNext, replace, setDefaultModel, size, swap, toString, toString, visitChildren, visitChildren, visitChildren, visitChildren
Methods inherited from class org.apache.wicket.Component
add, addStateChange, afterRender, beforeRender, canCallListenerInterface, checkComponentTag, checkComponentTagAttribute, checkHierarchyChange, configure, continueToOriginalDestination, debug, detach, detachModel, detachModels, determineVisibility, error, exceptionMessage, fatal, findMarkupStream, findPage, findParent, findParentWithAssociatedMarkup, getAjaxRegionMarkupId, getApplication, getBehaviorById, getBehaviorId, getBehaviors, getBehaviors, getClassRelativePath, getConverter, getDefaultModel, getDefaultModelObject, getDefaultModelObjectAsString, getDefaultModelObjectAsString, getEscapeModelStrings, getFeedbackMessage, getFeedbackMessages, getFlag, getId, getInnermostModel, getInnermostModel, getLocale, getLocalizer, getMarkup, getMarkupAttributes, getMarkupId, getMarkupId, getMarkupIdFromMarkup, getMarkupIdImpl, getMarkupSourcingStrategy, getMetaData, getModelComparator, getOutputMarkupId, getOutputMarkupPlaceholderTag, getPage, getPageRelativePath, getParent, getPath, getRenderBodyOnly, getRequest, getRequestCycle, getRequestFlag, getResponse, getSession, getSizeInBytes, getStatelessHint, getString, getString, getString, getStyle, getVariation, hasBeenRendered, hasErrorMessage, hasFeedbackMessage, info, initModel, internalOnModelChanged, internalPrepareForRender, internalRenderComponent, isActionAuthorized, isAuto, isBehaviorAccepted, isEnableAllowed, isEnabled, isEnabledInHierarchy, isIgnoreAttributeModifier, isRenderAllowed, isStateless, isVersioned, isVisibilityAllowed, isVisibleInHierarchy, locateMarkupStream, markRendering, modelChanged, modelChanging, newMarkupSourcingStrategy, onAfterRender, onBeforeRender, onComponentTag, onConfigure, onDetach, onEvent, onModelChanged, onModelChanging, onRemove, prepareForRender, redirectToInterceptPage, remove, remove, render, renderComponentTag, rendered, renderHead, renderHead, renderHead, renderPlaceholderTag, replaceComponentTagBody, replaceWith, sameInnermostModel, sameInnermostModel, send, setAuto, setDefaultModelObject, setEnabled, setEscapeModelStrings, setFlag, setIgnoreAttributeModifier, setMarkup, setMarkupId, setMarkupIdImpl, setMetaData, setOutputMarkupId, setOutputMarkupPlaceholderTag, setParent, setRenderBodyOnly, setRequestFlag, setResponsePage, setResponsePage, setResponsePage, setVersioned, setVisibilityAllowed, setVisible, success, urlFor, urlFor, urlFor, urlFor, urlFor, visitParents, warn, wrap
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail


public Enclosure(java.lang.String id,
                 java.lang.CharSequence childId)

id -
childId -
Method Detail


public final java.lang.String getChildId()
child id


protected void onInitialize()
Description copied from class: Component
This method is meant to be used as an alternative to initialize components. Usually the component's constructor is used for this task, but sometimes a component cannot be initialized in isolation, it may need to access its parent component or its markup in order to fully initialize. This method is invoked once per component's lifecycle when a path exists from this component to the Page thus providing the component with an atomic callback when the component's environment is built out.

Overrides must call super#Component.onInitialize(). Usually this should be the first thing an override does, much like a constructor.

Parent containers are guaranteed to be initialized before their children

It is safe to use Component.getPage() in this method

NOTE:The timing of this call is not precise, the contract is that it is called sometime before Component.onBeforeRender().

onInitialize in class Component


protected final Component getChild()


public boolean isVisible()
Description copied from class: Component
Gets whether this component and any children are visible.

WARNING: this method can be called multiple times during a request. If you override this method, it is a good idea to keep it cheap in terms of processing. Alternatively, you can call Component.setVisible(boolean).

isVisible in class Component
True if component and any children are visible


protected MarkupContainer getEnclosureParent()
Get the real parent container

enclosure's parent markup container


public Component resolve(MarkupContainer container,
                         MarkupStream markupStream,
                         ComponentTag tag)
Description copied from interface: IComponentResolver
Try to resolve a component.

Specified by:
resolve in interface IComponentResolver
container - The container parsing its markup
markupStream - The current markupStream
tag - The current component tag while parsing the markup
component or null if not found

Copyright © 2006-2011 Apache Software Foundation. All Rights Reserved.