org.apache.wicket
public abstract class MarkupContainer extends Component implements Iterable<Component>
add(Component...)
method, and
they can be looked up using a colon separated path. For example, if a container called "a" held a
nested container "b" which held a nested component "c", then a.get("b:c") would return the
Component with id "c". The number of children in a MarkupContainer can be determined by calling
size(), and the whole hierarchy of children held by a MarkupContainer can be traversed by calling
visitChildren(), passing in an implementation of IVisitor.
Components may alter their referring tag, replace the tag's body or insert markup after the tag. But components cannot remove tags from the markup stream. This is an important guarantee because graphic designers may be setting attributes on component tags that affect visual presentation.
The type of markup held in a given container subclass can be determined by calling
getMarkupType()
. Markup is accessed via a MarkupStream object which allows a component
to traverse ComponentTag and RawMarkup MarkupElements while rendering a response. Markup in the
stream may be HTML or some other kind of markup, such as VXML, as determined by the specific
container subclass.
A markup stream may be directly associated with a container via setMarkupStream. However, a
container which does not have a markup stream (its getMarkupStream() returns null) may inherit a
markup stream from a container above it in the component hierarchy. The
Component.findMarkupStream()
method will locate the first container at or above this container
which has a markup stream.
All Page containers set a markup stream before rendering by calling the method
getAssociatedMarkupStream(boolean)
to load the markup associated with the page. Since
Page is at the top of the container hierarchy, it is guaranteed that Component.findMarkupStream()
will always return a valid markup stream.
MarkupStream
,
Serialized FormENABLE, FLAG_INITIALIZED, FLAG_REMOVING_FROM_HIERARCHY, FLAG_RESERVED1, FLAG_RESERVED2, FLAG_RESERVED3, FLAG_RESERVED4, FLAG_RESERVED5, FLAG_RESERVED8, PARENT_PATH, PATH_SEPARATOR, RENDER
Constructor and Description |
---|
MarkupContainer(String id) |
MarkupContainer(String id,
IModel<?> model) |
Modifier and Type | Method and Description |
---|---|
MarkupContainer |
add(Component... childs)
Adds a child component to this container.
|
MarkupContainer |
addOrReplace(Component... childs)
Replaces a child component of this container with another or just adds it in case no child
with the same id existed yet.
|
boolean |
autoAdd(Component component,
MarkupStream markupStream)
This method allows a component to be added by an auto-resolver such as AutoLinkResolver.
|
boolean |
contains(Component component,
boolean recurse) |
Component |
get(int index)
Returns child component at the specified index
|
Component |
get(String path)
Get a child component by looking it up with the given path.
|
Markup |
getAssociatedMarkup()
Gets a fresh markup stream that contains the (immutable) markup resource for this class.
|
MarkupStream |
getAssociatedMarkupStream(boolean throwException)
Gets a fresh markup stream that contains the (immutable) markup resource for this class.
|
IMarkupFragment |
getMarkup(Component child)
Get the childs markup
|
MarkupType |
getMarkupType()
Get the type of associated markup for this component.
|
void |
internalAdd(Component child)
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API.
|
void |
internalInitialize()
THIS METHOD IS NOT PART OF THE PUBLIC API, DO NOT CALL IT
Overrides
Component.internalInitialize() to call Component.fireInitialize()
for itself and for all its children. |
Iterator<Component> |
iterator() |
Iterator<Component> |
iterator(Comparator<Component> comparator) |
protected void |
onAfterRenderChildren() |
void |
onComponentTagBody(MarkupStream markupStream,
ComponentTag openTag)
Handle the container's body.
|
protected void |
onRender()
Implementation that renders this component.
|
MarkupContainer |
remove(Component component) |
MarkupContainer |
remove(String id)
Removes the given component
|
MarkupContainer |
removeAll()
Removes all children from this container.
|
protected void |
renderAll(MarkupStream markupStream,
ComponentTag openTag)
Loop through the markup in this container
|
void |
renderAssociatedMarkup(String openTagName,
String exceptionMessage)
Renders the entire associated markup for a container such as a Border or Panel.
|
protected boolean |
renderNext(MarkupStream markupStream)
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API.
|
MarkupContainer |
replace(Component child)
Replaces a child component of this container with another
|
MarkupContainer |
setDefaultModel(IModel<?> model)
Sets the given model.
|
int |
size()
Get the number of children in this container.
|
void |
swap(int idx1,
int idx2)
Swaps position of children.
|
String |
toString()
Gets the string representation of this component.
|
String |
toString(boolean detailed) |
ComponentHierarchyIterator |
visitChildren()
Deprecated.
ComponentHierarchyIterator is deprecated.
Use
visitChildren(org.apache.wicket.util.visit.IVisitor) instead |
ComponentHierarchyIterator |
visitChildren(Class<?> clazz)
Deprecated.
ComponentHierarchyIterator is deprecated.
Use
visitChildren(Class, org.apache.wicket.util.visit.IVisitor) instead. |
<S extends Component,R> |
visitChildren(Class<?> clazz,
IVisitor<S,R> visitor)
Traverses all child components of the given class in this container, calling the visitor's
visit method at each one.
|
<R> R |
visitChildren(IVisitor<Component,R> visitor)
Traverses all child components in this container, calling the visitor's visit method at each
one.
|
add, addStateChange, afterRender, beforeRender, canCallListenerInterface, checkComponentTag, checkComponentTagAttribute, checkHierarchyChange, clearOriginalDestination, 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, 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, isRendering, isStateless, isVersioned, isVisibilityAllowed, isVisible, isVisibleInHierarchy, markRendering, modelChanged, modelChanging, newMarkupSourcingStrategy, onAfterRender, onBeforeRender, onComponentTag, onConfigure, onDetach, onEvent, onInitialize, onModelChanged, onModelChanging, onReAdd, 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, visitParents, warn, wrap
public MarkupContainer(String id)
Component.Component(String)
public MarkupContainer(String id, IModel<?> model)
Component.Component(String, IModel)
public MarkupContainer add(Component... childs)
childs
- The child(ren) to add.IllegalArgumentException
- Thrown if a child with the same id is replaced by the add operation.public MarkupContainer addOrReplace(Component... childs)
childs
- The child(s) to be added or replacedpublic final boolean autoAdd(Component component, MarkupStream markupStream)
The result of all this is that components added with autoAdd() are free from versioning and can add their own children without the usual exception that would normally be thrown when the component hierarchy is modified during rendering.
component
- The component to addmarkupStream
- Null, if the parent container is able to provide the markup. Else the markup
stream to be used to render the component.public boolean contains(Component component, boolean recurse)
component
- The component to checkrecurse
- True if all descendents should be consideredpublic final Component get(String path)
A component path consists of component ids separated by colons, e.g. "b:c" identifies a component "c" inside container "b" inside this container.
get
in interface IRequestableComponent
get
in class Component
path
- path to componentpublic MarkupStream getAssociatedMarkupStream(boolean throwException)
throwException
- If true, throw an exception, if markup could not be foundpublic Markup getAssociatedMarkup()
public IMarkupFragment getMarkup(Component child)
child
- The child component. If null, the container's markup will be returned. See Border,
Panel or Enclosure where getMarkup(null) != getMarkup().Component.getMarkup()
public MarkupType getMarkupType()
public void internalAdd(Component child)
child
- The childIllegalArgumentException
- Thrown if a child with the same id is replaced by the add operation.public final Iterator<Component> iterator(Comparator<Component> comparator)
comparator
- The comparatorpublic MarkupContainer remove(Component component)
component
- Component to remove from this containerthis
for chainingpublic MarkupContainer remove(String id)
id
- The id of the component to removethis
for chainingpublic MarkupContainer removeAll()
Note: implementation does not call remove(Component)
for each
component.
this
for method chainingpublic final void renderAssociatedMarkup(String openTagName, String exceptionMessage)
openTagName
- the tag to render the associated markup forexceptionMessage
- message that will be used for exceptionspublic MarkupContainer replace(Component child)
child
- The childIllegalArgumentException
- Thrown if there was no child with the same id.public MarkupContainer setDefaultModel(IModel<?> model)
Component
WARNING: DO NOT OVERRIDE THIS METHOD UNLESS YOU HAVE A VERY GOOD REASON FOR IT. OVERRIDING THIS MIGHT OPEN UP SECURITY LEAKS AND BREAK BACK-BUTTON SUPPORT.
setDefaultModel
in class Component
model
- The modelComponent.setDefaultModel(org.apache.wicket.model.IModel)
public int size()
public String toString()
Component
toString
in class Component
Component.toString()
public String toString(boolean detailed)
public final <S extends Component,R> R visitChildren(Class<?> clazz, IVisitor<S,R> visitor)
S
- The type that goes into the Visitor.component() method.R
- clazz
- The class of child to visitvisitor
- The visitor to call back topublic final <R> R visitChildren(IVisitor<Component,R> visitor)
R
- visitor
- The visitor to call back to@Deprecated public final ComponentHierarchyIterator visitChildren()
visitChildren(org.apache.wicket.util.visit.IVisitor)
instead@Deprecated public final ComponentHierarchyIterator visitChildren(Class<?> clazz)
visitChildren(Class, org.apache.wicket.util.visit.IVisitor)
instead.clazz
- Filter conditionpublic final void internalInitialize()
Component.internalInitialize()
to call Component.fireInitialize()
for itself and for all its children.internalInitialize
in class Component
Component.fireInitialize()
public final Component get(int index)
index
- ArrayIndexOutOfBoundsException
protected boolean renderNext(MarkupStream markupStream)
markupStream
- The markup streampublic void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag)
onComponentTagBody
in class Component
markupStream
- The markup streamopenTag
- The open tag for the bodyprotected void onRender()
Component
onRender
in class Component
Component.onRender()
protected final void renderAll(MarkupStream markupStream, ComponentTag openTag)
markupStream
- openTag
- protected void onAfterRenderChildren()
onAfterRenderChildren
in class Component
public final void swap(int idx1, int idx2)
idx1
- index of first component to be swappedidx2
- index of second component to be swappedCopyright © 2006–2018 Apache Software Foundation. All rights reserved.