|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.wicket.Component org.apache.wicket.MarkupContainer
public abstract class MarkupContainer
A MarkupContainer holds a map of child components.
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 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() to load the markup associated with the page. Since Page is at the top of the container hierarchy, it is guaranteed that findMarkupStream will always return a valid markup stream.
MarkupStream
,
Serialized FormNested Class Summary |
---|
Nested classes/interfaces inherited from class org.apache.wicket.Component |
---|
Component.ComponentModelChange, Component.EnabledChange, Component.IVisitor, Component.VisibilityChange |
Field Summary |
---|
Fields inherited from class org.apache.wicket.Component |
---|
ENABLE, FLAG_RESERVED1, FLAG_RESERVED2, FLAG_RESERVED3, FLAG_RESERVED4, FLAG_RESERVED5, FLAG_RESERVED6, FLAG_RESERVED7, FLAG_RESERVED8, PATH_SEPARATOR, RENDER |
Constructor Summary | |
---|---|
MarkupContainer(java.lang.String id)
|
|
MarkupContainer(java.lang.String id,
IModel model)
|
Method Summary | |
---|---|
MarkupContainer |
add(Component child)
Adds a child component to this container. |
MarkupContainer |
addOrReplace(Component child)
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)
Deprecated. since 1.3 Please use autoAdd(Component, MarkupStream) instead |
boolean |
autoAdd(Component component,
MarkupStream markupStream)
This method allows a component to be added by an auto-resolver such as AutoComponentResolver or AutoLinkResolver. |
boolean |
contains(Component component,
boolean recurse)
|
protected MarkupStream |
findMarkupStream()
Get the markup stream for this component. |
Component |
get(java.lang.String path)
Get a child component by looking it up with the given path. |
MarkupStream |
getAssociatedMarkupStream(boolean throwException)
Gets a fresh markup stream that contains the (immutable) markup resource for this class. |
MarkupStream |
getMarkupStream()
Get the markup stream set on this container. |
java.lang.String |
getMarkupType()
Get the type of associated markup for this component. |
boolean |
hasAssociatedMarkup()
|
void |
internalAdd(Component child)
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. |
boolean |
isTransparentResolver()
Some MarkupContainers (e.g. |
java.util.Iterator |
iterator()
|
java.util.Iterator |
iterator(java.util.Comparator comparator)
|
IResourceStream |
newMarkupResourceStream(java.lang.Class containerClass)
NOT USED ANYMORE; it's here for helping people migrate from Wicket 1.2 to Wicket 1.3 |
protected void |
onComponentTagBody(MarkupStream markupStream,
ComponentTag openTag)
Handle the container's body. |
protected void |
onRender(MarkupStream markupStream)
Renders this component. |
void |
remove(Component component)
|
void |
remove(java.lang.String id)
Removes the given component |
void |
removeAll()
Removes all children from this container. |
protected void |
renderAll(MarkupStream markupStream)
Renders this component and all sub-components using the given markup stream. |
void |
renderAssociatedMarkup(java.lang.String openTagName,
java.lang.String exceptionMessage)
Renders the entire associated markup stream for a container such as a Border or Panel. |
protected void |
renderComponentTagBody(MarkupStream markupStream,
ComponentTag openTag)
Renders markup for the body of a ComponentTag from the current position in the given markup stream. |
MarkupContainer |
replace(Component child)
Replaces a child component of this container with another |
protected void |
setMarkupStream(MarkupStream markupStream)
Set markup stream for this container. |
Component |
setModel(IModel model)
Sets the given model. |
int |
size()
Get the number of children in this container. |
java.lang.String |
toString()
Gets the string representation of this component. |
java.lang.String |
toString(boolean detailed)
|
java.lang.Object |
visitChildren(java.lang.Class clazz,
Component.IVisitor visitor)
Traverses all child components of the given class in this container, calling the visitor's visit method at each one. |
java.lang.Object |
visitChildren(Component.IVisitor visitor)
Traverses all child components in this container, calling the visitor's visit method at each one. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public MarkupContainer(java.lang.String id)
Component.Component(String)
public MarkupContainer(java.lang.String id, IModel model)
Component.Component(String, IModel)
Method Detail |
---|
public final MarkupContainer add(Component child)
child
- The child
java.lang.IllegalArgumentException
- Thrown if a child with the same id is replaced by the add operation.public final MarkupContainer addOrReplace(Component child)
child
- The child
public 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 final boolean autoAdd(Component component)
autoAdd(Component, MarkupStream)
instead
component
- The component to add
public final boolean contains(Component component, boolean recurse)
component
- The component to checkrecurse
- True if all descendents should be considered
public final Component get(java.lang.String path)
path
- Path to component
public MarkupStream getAssociatedMarkupStream(boolean throwException)
throwException
- If true, throw an exception, if markup could not be found
public final MarkupStream getMarkupStream()
public java.lang.String getMarkupType()
public void internalAdd(Component child)
child
- The child
java.lang.IllegalArgumentException
- Thrown if a child with the same id is replaced by the add operation.public boolean isTransparentResolver()
ParentResolver
public final java.util.Iterator iterator()
public final java.util.Iterator iterator(java.util.Comparator comparator)
comparator
- The comparator
public final IResourceStream newMarkupResourceStream(java.lang.Class containerClass)
containerClass
-
java.lang.IllegalStateException
- throws an IllegalStateException
public void remove(Component component)
component
- Component to remove from this containerpublic final void remove(java.lang.String id)
id
- The id of the component to removepublic final void removeAll()
Note: implementation does not call remove(Component)
for each
component.
public final void renderAssociatedMarkup(java.lang.String openTagName, java.lang.String exceptionMessage)
openTagName
- the tag to render the associated markup forexceptionMessage
- message that will be used for exceptionspublic final MarkupContainer replace(Component child)
child
- The child
java.lang.IllegalArgumentException
- Thrown if there was no child with the same id.public Component setModel(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.
model
- The model
Component.setModel(org.apache.wicket.model.IModel)
public final int size()
public java.lang.String toString()
Component
Component.toString()
public java.lang.String toString(boolean detailed)
detailed
- True if a detailed string is desired
public final java.lang.Object visitChildren(java.lang.Class clazz, Component.IVisitor visitor)
clazz
- The class of child to visit, or null to visit all childrenvisitor
- The visitor to call back to
public final java.lang.Object visitChildren(Component.IVisitor visitor)
visitor
- The visitor to call back to
protected final MarkupStream findMarkupStream()
findMarkupStream
in class Component
protected void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag)
onComponentTagBody
in class Component
markupStream
- The markup streamopenTag
- The open tag for the bodyprotected void onRender(MarkupStream markupStream)
markupStream
- protected void renderAll(MarkupStream markupStream)
markupStream
- The markup streamprotected final void renderComponentTagBody(MarkupStream markupStream, ComponentTag openTag)
markupStream
- The markup streamopenTag
- The open tagprotected final void setMarkupStream(MarkupStream markupStream)
setMarkupStream
in class Component
markupStream
- The markup streamComponent.findMarkupStream()
,
getMarkupStream()
public boolean hasAssociatedMarkup()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |