|
||||||||||
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<T extends Component>, Component.VisibilityChange |
Field Summary |
---|
Fields inherited from class org.apache.wicket.Component |
---|
ENABLE, FLAG_CONFIGURED, FLAG_INITIALIZED, FLAG_REMOVING_FROM_HIERARCHY, FLAG_RESERVED1, FLAG_RESERVED2, FLAG_RESERVED3, FLAG_RESERVED4, FLAG_RESERVED5, FLAG_RESERVED6, FLAG_RESERVED7, FLAG_RESERVED8, PARENT_PATH, PATH_SEPARATOR, RENDER |
Constructor Summary | |
---|---|
MarkupContainer(String id)
|
|
MarkupContainer(String id,
IModel<?> model)
|
Method Summary | ||
---|---|---|
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)
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(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. |
|
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. |
|
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. |
|
Iterator<? extends Component> |
iterator()
|
|
Iterator<Component> |
iterator(Comparator<Component> comparator)
|
|
|
newMarkupResourceStream(Class<C> containerClass)
NOT USED ANYMORE; it's here for helping people migrate from Wicket 1.2 to Wicket 1.3 |
|
protected void |
onAfterRenderChildren()
|
|
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(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(String openTagName,
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. |
|
protected void |
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. |
|
protected void |
setMarkupStream(MarkupStream markupStream)
Set markup stream for this container. |
|
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)
|
|
|
visitChildren(Class<?> clazz,
Component.IVisitor<S> visitor)
Traverses all child components of the given class in this container, calling the visitor's visit method at each one. |
|
Object |
visitChildren(Component.IVisitor<Component> 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(String id)
Component.Component(String)
public MarkupContainer(String id, IModel<?> model)
Component.Component(String, IModel)
Method Detail |
---|
public final MarkupContainer add(Component... childs)
childs
- The child(s)
IllegalArgumentException
- Thrown if a child with the same id is replaced by the add operation.public final MarkupContainer addOrReplace(Component... childs)
childs
- The child(s) to be added or replaced
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.
@Deprecated 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(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 String getMarkupType()
public void internalAdd(Component child)
child
- The child
IllegalArgumentException
- Thrown if a child with the same id is replaced by the add operation.public boolean isTransparentResolver()
ParentResolver
public Iterator<? extends Component> iterator()
public final Iterator<Component> iterator(Comparator<Component> comparator)
comparator
- The comparator
public final <C extends Component> IResourceStream newMarkupResourceStream(Class<C> containerClass)
C
- containerClass
-
IllegalStateException
- throws an IllegalStateException
public void remove(Component component)
component
- Component to remove from this containerpublic final void remove(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(String openTagName, 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
IllegalArgumentException
- 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 model
Component.setDefaultModel(org.apache.wicket.model.IModel)
public final int size()
public String toString()
Component
Component.toString()
public String toString(boolean detailed)
detailed
- True if a detailed string is desired
public final <S extends Component> Object visitChildren(Class<?> clazz, Component.IVisitor<S> visitor)
S
- The type that goes into the Visitor.component() method.clazz
- The class of child to visit, or null to visit all childrenvisitor
- The visitor to call back to
public final Object visitChildren(Component.IVisitor<Component> visitor)
visitor
- The visitor to call back to
public final Component get(int index)
index
-
ArrayIndexOutOfBoundsException
protected final void renderNext(MarkupStream markupStream)
markupStream
- The markup streamprotected 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()
protected void onAfterRenderChildren()
Component.onAfterRenderChildren()
public boolean hasAssociatedMarkup()
public final void swap(int idx1, int idx2)
idx1
- index of first component to be swappedidx2
- index of second component to be swapped
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |