Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
   /*
    * Licensed to the Apache Software Foundation (ASF) under one or more
    * contributor license agreements.  See the NOTICE file distributed with
    * this work for additional information regarding copyright ownership.
    * The ASF licenses this file to You under the Apache License, Version 2.0
    * (the "License"); you may not use this file except in compliance with
    * the License.  You may obtain a copy of the License at
    *
    *      http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  package org.apache.wicket;
  
  import java.util.Arrays;
  import java.util.List;
  
  import org.slf4j.Logger;
A MarkupContainer holds a map of child components.
  • Children - Children can be added by calling the add() method, and they can be looked up using a dotted 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 Component.IVisitor.
  • Markup Rendering - A MarkupContainer also holds/references associated markup which is used to render the container. As the markup stream for a container is rendered, component references in the markup are resolved by using the container to look up Components in the container's component map by id. Each component referenced by the markup stream is given an opportunity to render itself using the markup stream.

    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.

    Author(s):
    Jonathan Locke
    See also:
    org.apache.wicket.markup.MarkupStream
  
  public abstract class MarkupContainer extends Component
  {
  	private static final long serialVersionUID = 1L;

Log for reporting.
  
  	private static final Logger log = LoggerFactory.getLogger(MarkupContainer.class);

List of children or single child
  
  	private Object children;

The markup stream for this container. This variable is used only during the render phase to provide access to the current element within the stream.
  
  	private transient MarkupStream markupStream;

See also:
org.apache.wicket.Component.Component.(java.lang.String)
 
 	public MarkupContainer(final String id)
 	{
 		super(id);
 	}

 
 	public MarkupContainer(final String idIModel model)
 	{
 		super(idmodel);
 	}

Adds a child component to this container.

Parameters:
child The child
Returns:
This
Throws:
java.lang.IllegalArgumentException Thrown if a child with the same id is replaced by the add operation.
 
 	public final MarkupContainer add(final Component child)
 	{
 
 		if (child == null)
 		{
 			throw new IllegalArgumentException("argument child may not be null");
 		}
 
 		{
 			.debug("Add " + child.getId() + " to " + this);
 		}
 
 		// Add to map
 		if (put(child) != null)
 		{
 			throw new IllegalArgumentException(exceptionMessage("A child with id '" +
 				child.getId() + "' already exists"));
 		}
 
 		return this;
 	}

Replaces a child component of this container with another or just adds it in case no child with the same id existed yet.

Parameters:
child The child
Returns:
This
 
 	public final MarkupContainer addOrReplace(final Component child)
 	{
 
 		if (child == null)
 		{
 			throw new IllegalArgumentException("argument child must be not null");
 		}
 
 		if (get(child.getId()) == null)
 		{
 			add(child);
 		}
 		else
 		{
 			replace(child);
 		}
 
 		return this;
 	}

This method allows a component to be added by an auto-resolver such as AutoComponentResolver or AutoLinkResolver. While the component is being added, the component's FLAG_AUTO boolean is set. The isAuto() method of Component returns true if a component or any of its parents has this bit set. When a component is added via autoAdd(), the logic in Page that normally (a) checks for modifications during the rendering process, and (b) versions components, is bypassed if Component.isAuto() returns true.

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.

Parameters:
component The component to add
markupStream Null, if the parent container is able to provide the markup. Else the markup stream to be used to render the component.
Returns:
True, if component has been added
 
 	public final boolean autoAdd(final Component componentfinal MarkupStream markupStream)
 	{
 		if (component == null)
 		{
 			throw new IllegalArgumentException("argument component may not be null");
 		}
 
 		/* Replace strategy */
 		component.setAuto(true);
 
 		int index = children_indexOf(component);
 		if (index >= 0)
 		{
 		}
 		add(component);
 		component.prepareForRender();
 		try
 		{
 			if (markupStream == null)
 			{
 				component.render();
 			}
 			else
 			{
 				component.render(markupStream);
 			}
 		}
 		finally
 		{
 			component.afterRender();
 		}
 		return true;
 	}

Deprecated:
since 1.3 Please use autoAdd(org.apache.wicket.Component,org.apache.wicket.markup.MarkupStream) instead
Parameters:
component The component to add
Returns:
True, if component has been added
 
 	public final boolean autoAdd(final Component component)
 	{
 		return autoAdd(componentnull);
 	}

Parameters:
component The component to check
recurse True if all descendents should be considered
Returns:
True if the component is contained in this container
 
 	public final boolean contains(final Component componentfinal boolean recurse)
 	{
 		if (component == null)
 		{
 			throw new IllegalArgumentException("argument component may not be null");
 		}
 
 		if (recurse)
 		{
 			// Start at component and continue while we're not out of parents
 			for (Component current = componentcurrent != null;)
 			{
 				// Get parent
 				final MarkupContainer parent = current.getParent();
 
 				// If this container is the parent, then the component is
 				// recursively contained by this container
 				if (parent == this)
 				{
 					// Found it!
 					return true;
 				}
 
 				// Move up the chain to the next parent
 				current = parent;
 			}
 
 			// Failed to find this container in component's ancestry
 			return false;
 		}
 		else
 		{
 			// Is the component contained in this container?
 			return component.getParent() == this;
 		}
 	}

Get a child component by looking it up with the given path.

Parameters:
path Path to component
Returns:
The component at the path
 
 	public final Component get(final String path)
 	{
 		// Reference to this container
 		if (path == null || path.trim().equals(""))
 		{
 			return this;
 		}
 
 		// Get child's id, if any
 		final String id = Strings.firstPathComponent(path.);
 
 		// Get child by id
 		Component child = children_get(id);
 
 		// If the container is transparent, than ask its parent.
 		// ParentResolver does something quite similar, but because of <head>,
 		// <body>, <wicket:panel> etc. it is quite common to have transparent
 		// components. Hence, this is little short cut for a tiny performance
 		// optimization.
 		if ((child == null) && isTransparentResolver() && (getParent() != null))
 		{
 			child = getParent().get(path);
 		}
 
 		// Found child?
 		if (child != null)
 		{
 			final String path2 = Strings.afterFirstPathComponent(path.);
 			// Recurse on latter part of path
 			return child.get(path2);
 		}
 
 		return child;
 	}

Gets a fresh markup stream that contains the (immutable) markup resource for this class.

Parameters:
throwException If true, throw an exception, if markup could not be found
Returns:
A stream of MarkupElement elements
 
 	public MarkupStream getAssociatedMarkupStream(final boolean throwException)
 	{
 		try
 		{
 				falsethrowException);
 		}
 		catch (MarkupException ex)
 		{
 			// re-throw it. The exception contains already all the information
 			// required.
 			throw ex;
 		}
 		{
 			// throw exception since there is no associated markup
 				exceptionMessage("Markup of type '" + getMarkupType() + "' for component '" +
 					getClass().getName() + "' not found." +
 					" Enable debug messages for org.apache.wicket.util.resource to get a list of all filenames tried"),
 				ex);
 		}
 	}


Get the markup stream set on this container.

Returns:
Returns the markup stream set on this container.
 
 	public final MarkupStream getMarkupStream()
 	{
 		return ;
 	}


Get the type of associated markup for this component.

Returns:
The type of associated markup for this component (for example, "html", "wml" or "vxml"). The markup type for a component is independent of whether or not the component actually has an associated markup resource file (which is determined at runtime). If there is no markup type for a component, null may be returned, but this means that no markup can be loaded for the class.
 
 	public String getMarkupType()
 	{
 		throw new IllegalStateException(
 			exceptionMessage("You cannot directly subclass Page or MarkupContainer.	 Instead, subclass a markup-specific class, such as WebPage or WebMarkupContainer"));
 	}

THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT USE IT. Adds a child component to this container.

Parameters:
child The child
Throws:
java.lang.IllegalArgumentException Thrown if a child with the same id is replaced by the add operation.
 
 	public void internalAdd(final Component child)
 	{
 		{
 			.debug("internalAdd " + child.getId() + " to " + this);
 		}
 
 		// Add to map
 		put(child);
 	}

Some MarkupContainers (e.g. HtmlHeaderContainer) have to be transparent with respect to their child components. A transparent container gets its children from its parent container.

Returns:
false. By default a MarkupContainer is not transparent.
See also:
org.apache.wicket.markup.resolver.ParentResolver
 
 	public boolean isTransparentResolver()
 	{
 		return false;
 	}

Returns:
Iterator that iterates through children in the order they were added
 
 	public final Iterator iterator()
 	{
 		return new Iterator()
 		{
 			int index = 0;
 
 			public boolean hasNext()
 			{
 				return  < children_size();
 			}
 
 			public Object next()
 			{
 				return children_get(++);
 			}
 
 			public void remove()
 			{
 				final Component removed = children_remove(--);
 				removedComponent(removed);
 			}
 		};
 	}

Parameters:
comparator The comparator
Returns:
Iterator that iterates over children in the order specified by comparator
 
 	public final Iterator iterator(Comparator comparator)
 	{
 		final List sorted;
 		if ( == null)
 		{
 			sorted = .;
 		}
 		else
 		{
 			if ( instanceof Component)
 			{
 				sorted = new ArrayList(1);
 				sorted.add();
 			}
 			else
 			{
 				sorted = Arrays.asList((Component[]));
 			}
 		}
 		Collections.sort(sortedcomparator);
 		return sorted.iterator();
 	}

NOT USED ANYMORE; it's here for helping people migrate from Wicket 1.2 to Wicket 1.3

Parameters:
containerClass
Returns:
nothing
Throws:
java.lang.IllegalStateException throws an java.lang.IllegalStateException
 
 	// TODO remove after release 1.3.0
 	public final IResourceStream newMarkupResourceStream(Class containerClass)
 	{
 		throw new IllegalStateException(
 			"this method is not used any more (and shouldn't be called by clients anyway)");
 	}

Parameters:
component Component to remove from this container
 
 	public void remove(final Component component)
 	{
 
 		if (component == null)
 		{
 			throw new IllegalArgumentException("argument component may not be null");
 		}
 
 		children_remove(component);
 		removedComponent(component);
 	}

Removes the given component

Parameters:
id The id of the component to remove
 
 	public final void remove(final String id)
 	{
 		if (id == null)
 		{
 			throw new IllegalArgumentException("argument id may not be null");
 		}
 
 		final Component component = get(id);
 		if (component != null)
 		{
 			remove(component);
 		}
 		else
 		{
 			throw new WicketRuntimeException("Unable to find a component with id '" + id +
 				"' to remove");
 		}
 	}

Removes all children from this container.

Note: implementation does not call for each component.

 
 	public final void removeAll()
 	{
 		if ( != null)
 		{
 			{
 				private static final long serialVersionUID = 1L;
 
 
 				public String toString()
 				{
 					return "RemoveAllChange[component: " + getPath() + ", removed Children: " +
 						 + "]";
 				}
 
 				public void undo()
 				{
 					int size = children_size();
 					for (int i = 0; i < sizei++)
 					{
 						// Get next child
 						final Component child = children_get(i);
 					}
 				}
 			});
 
 			// Loop through child components
 			int size = children_size();
 			for (int i = 0; i < sizei++)
 			{
 				// Get next child
 				final Component child = children_get(i);
 
 				// Do not call remove() because the state change would than be
 				// recorded twice.
 				child.detachModel();
 				child.setParent(null);
 			}
 
 			 = null;
 		}
 	}

Renders the entire associated markup stream for a container such as a Border or Panel. Any leading or trailing raw markup in the associated markup is skipped.

Parameters:
openTagName the tag to render the associated markup for
exceptionMessage message that will be used for exceptions
 
 	public final void renderAssociatedMarkup(final String openTagNamefinal String exceptionMessage)
 	{
 		// Get markup associated with Border or Panel component
 		final MarkupStream originalMarkupStream = getMarkupStream();
 		final MarkupStream associatedMarkupStream = getAssociatedMarkupStream(true);
 
 		// skip until the targetted tag is found
 		associatedMarkupStream.skipUntil(openTagName);
 		setMarkupStream(associatedMarkupStream);
 
 		// Get open tag in associated markup of border component
 		final ComponentTag associatedMarkupOpenTag = associatedMarkupStream.getTag();
 
 		// Check for required open tag name
 		if (!((associatedMarkupOpenTag != null) && associatedMarkupOpenTag.isOpen() && (associatedMarkupOpenTag instanceof WicketTag)))
 		{
 			associatedMarkupStream.throwMarkupException(exceptionMessage);
 		}
 
 		try
 		{
 			renderComponentTag(associatedMarkupOpenTag);
 			associatedMarkupStream.next();
 
 			{
 				getResponse().write("<!-- MARKUP FOR ");
 				getResponse().write(" BEGIN -->");
 			}
 
 			renderComponentTagBody(associatedMarkupStreamassociatedMarkupOpenTag);
 
 			{
 				getResponse().write("<!-- MARKUP FOR ");
 				getResponse().write(" END -->");
 			}
 
 			renderClosingComponentTag(associatedMarkupStreamassociatedMarkupOpenTagfalse);
 			setMarkupStream(originalMarkupStream);
 		}
 		finally
 		{
 		}
 	}

Replaces a child component of this container with another

Parameters:
child The child
Returns:
This
Throws:
java.lang.IllegalArgumentException Thrown if there was no child with the same id.
 
 	public final MarkupContainer replace(final Component child)
 	{
 
 		if (child == null)
 		{
 			throw new IllegalArgumentException("argument child must be not null");
 		}
 
 		{
 			.debug("Replacing " + child.getId() + " in " + this);
 		}
 
 		if (child.getParent() != this)
 		{
 			// Add to map
 			final Component replaced = put(child);
 
 			// Look up to make sure it was already in the map
 			if (replaced == null)
 			{
 					exceptionMessage("Cannot replace a component which has not been added: id='" +
 						child.getId() + "', component=" + child));
 			}
 
 			// first remove the component.
 			removedComponent(replaced);
 
 			// then add the other one.
 
 			// The position of the associated markup remains the same
 			child.markupIndex = replaced.markupIndex;
 
 			// The generated markup id remains the same
 			child.setMarkupIdImpl(replaced.getMarkupIdImpl());
 		}
 
 		return this;
 	}

 
 	public Component setModel(final IModel model)
 	{
 		final IModel previous = getModelImpl();
 		super.setModel(model);
 		if (previous instanceof IComponentInheritedModel)
 		{
 			{
 				public Object component(Component component)
 				{
 					IModel compModel = component.getModel();
 					if (compModel instanceof IWrapModel)
 					{
 						compModel = ((IWrapModel)compModel).getWrappedModel();
 					}
 					if (compModel == previous)
 					{
 						component.setModel(null);
 					}
 					else if (compModel == model)
 					{
 						component.modelChanged();
 					}
 				}
 
 			});
 		}
 		return this;
 	}

Get the number of children in this container.

Returns:
Number of children in this container
 
 	public final int size()
 	{
 		return children_size();
 	}

 
 	public String toString()
 	{
 		return toString(false);
 	}

Parameters:
detailed True if a detailed string is desired
Returns:
String representation of this container
 
 	public String toString(final boolean detailed)
 	{
 		final StringBuffer buffer = new StringBuffer();
 		buffer.append("[MarkupContainer ");
 		buffer.append(super.toString(true));
 		if (detailed)
 		{
 			if (getMarkupStream() != null)
 			{
 				buffer.append(", markupStream = " + getMarkupStream());
 			}
 
 			if (children_size() != 0)
 			{
 				buffer.append(", children = ");
 
 				// Loop through child components
 				final int size = children_size();
 				for (int i = 0; i < sizei++)
 				{
 					// Get next child
 					final Component child = children_get(i);
 					if (i != 0)
 					{
 						buffer.append(' ');
 					}
 					buffer.append(child.toString());
 				}
 			}
 		}
 		buffer.append(']');
 		return buffer.toString();
 	}

Traverses all child components of the given class in this container, calling the visitor's visit method at each one.

Parameters:
clazz The class of child to visit, or null to visit all children
visitor The visitor to call back to
Returns:
The return value from a visitor which halted the traversal, or null if the entire traversal occurred
 
 	public final Object visitChildren(final Class clazzfinal IVisitor visitor)
 	{
 		if (visitor == null)
 		{
 			throw new IllegalArgumentException("argument visitor may not be null");
 		}
 
 		// Iterate through children of this container
 		for (int i = 0; i < children_size(); i++)
 		{
 			// Get next child component
 			final Component child = children_get(i);
 			Object value = null;
 
 			// Is the child of the correct class (or was no class specified)?
 			if (clazz == null || clazz.isInstance(child))
 			{
 				// Call visitor
 				value = visitor.component(child);
 
 				// If visitor returns a non-null value, it halts the traversal
 				if ((value != .) &&
 				{
 					return value;
 				}
 			}
 
 			// If child is a container
 			if ((child instanceof MarkupContainer) &&
 			{
 				// visit the children in the container
 				value = ((MarkupContainer)child).visitChildren(clazzvisitor);
 
 				// If visitor returns a non-null value, it halts the traversal
 				if ((value != .) &&
 				{
 					return value;
 				}
 			}
 		}
 
 		return null;
 	}

Traverses all child components in this container, calling the visitor's visit method at each one.

Parameters:
visitor The visitor to call back to
Returns:
The return value from a visitor which halted the traversal, or null if the entire traversal occurred
 
 	public final Object visitChildren(final IVisitor visitor)
 	{
 		return visitChildren(nullvisitor);
 	}

Parameters:
component Component being added
 
 	private final void addedComponent(final Component component)
 	{
 		// Check for degenerate case
 		if (component == this)
 		{
 			throw new IllegalArgumentException("Component can't be added to itself");
 		}
 
 		MarkupContainer parent = component.getParent();
 		if (parent != null)
 		{
 			parent.remove(component);
 		}
 
 		// Set child's parent
 		component.setParent(this);
 
 		final Page page = findPage();
 
 		final IDebugSettings debugSettings = Application.get().getDebugSettings();
 		{
 			component.setMetaData(, Strings.toString(componentnew MarkupException(
 				"added")));
 		}
 
 		if (page != null)
 		{
 			page.componentAdded(component);
 		}
 
 		// if the PREPARED_FOR_RENDER flag is set, we have already called
 		// beforeRender on this
 		// component's children. So we need to initialize the newly added one
 		{
 			component.beforeRender();
 		}
 	}

Parameters:
child Child to add
 
 	private final void children_add(final Component child)
 	{
 		if ( == null)
 		{
 			 = child;
 		}
 		else
 		{
 			// Get current list size
 			final int size = children_size();
 
 			// Create array that holds size + 1 elements
 			final Object[] children = new Object[size + 1];
 
 			// Loop through existing children copying them
 			for (int i = 0; i < sizei++)
 			{
 				children[i] = children_get(ifalse);
 			}
 
 			// Add new child to the end
 			children[size] = child;
 
 			// Save new children
 			this. = children;
 		}
 	}
 
 	private final Component children_get(int index)
 	{
 		return (Component)children_get(indextrue);
 	}

If the given object is a MarkupContainer.ComponentSourceEntry instance and reconstruct is true, it reconstructs the component and returns it. Otherwise it just returns the object passed as parameter

Parameters:
object
reconstruct
parent
index
Returns:
 
 	private final Object postprocess(Object objectboolean reconstructMarkupContainer parent,
 		int index)
 	{
 		if (reconstruct && object instanceof ComponentSourceEntry)
 		{
 			object = ((ComponentSourceEntry)object).reconstruct(parentindex);
 		}
 		return object;
 	}
 
 	private final Object children_get(int indexboolean reconstruct)
 	{
 		Object component = null;
 		if (index == 0 &&  != null &&  instanceof Object[] == false)
 		{
 			component = postprocess(reconstructthis, 0);
 			if ( != component)
 			{
 				 = component;
 			}
 		}
 		else
 		{
 			// we have a list
 			Object[] children = (Object[])this.;
 			component = postprocess(children[index], reconstructthisindex);
 			if (children[index] != component)
 			{
 				children[index] = component;
 			}
 		}
 
 		return component;
 	}

Returns the wicket:id of the given object, that can be either a Component or a MarkupContainer.ComponentSourceEntry

Parameters:
object
Returns:
 
 	private final String getId(Object object)
 	{
		if (object instanceof Component)
			return ((Component)object).getId();
		else if (object instanceof ComponentSourceEntry)
			return ((ComponentSourceEntry)object).;
		else
			throw new IllegalArgumentException("Unknown type of object " + object);
	private final Component children_get(final String id)
		Component component = null;
		if ( != null &&  instanceof Object[] == false && getId().equals(id))
			component = (Component)postprocess(truethis, 0);
			if ( != component)
				 = component;
		else if ( instanceof Object[])
			final Object[] children = (Object[])this.;
				for (int i = 0; i < children.lengthi++)
					if (getId(children[i]).equals(id))
						component = (Component)postprocess(children[i], truethisi);
						if (children[i] != component)
							children[i] = component;
						break;
		return component;
	private final int children_indexOf(Component child)
		if ( != null &&  instanceof Object[] == false &&
			return 0;
		else if ( instanceof Object[])
			final Object[] children = (Object[])this.;
			for (int i = 0; i < children.lengthi++)
				if (getId(children[i]).equals(child.getId()))
					return i;
		return -1;
	private final Component children_remove(Component component)
		int index = children_indexOf(component);
		if (index != -1)
			return children_remove(index);
		return null;
	private final Component children_remove(int index)
		if ( instanceof Component ||  instanceof ComponentSourceEntry)
			if (index == 0)
				final Component removed = (Component)postprocess(truenull, -1);
				 = null;
				return removed;
			else
		else
			Object[] c = ((Object[]));
			final Object removed = c[index];
			if (c.length == 2)
				if (index == 0)
					 = c[1];
				else if (index == 1)
					 = c[0];
				else
			else
				Object[] newChildren = new Object[c.length - 1];
				int j = 0;
				for (int i = 0; i < c.lengthi++)
					if (i != index)
						newChildren[j++] = c[i];
				 = newChildren;
			return (Component)postprocess(removedtruenull, -1);
	private final Object children_set(int indexObject childboolean reconstruct)
		Object replaced;
		if (index < children_size())
			if ( == null ||  instanceof Component ||
				replaced = ;
				 = child;
			else
				final Object[] children = (Object[])this.;
				replaced = children[index];
				children[index] = child;
		else
		return postprocess(replacedreconstructnull, -1);
	private final Component children_set(int indexComponent child)
		return (Component)children_set(indexchildtrue);
	private final int children_size()
		if ( == null)
			return 0;
		else
			if ( instanceof Component ||  instanceof ComponentSourceEntry)
				return 1;
			return ((Object[])).length;
	}

Ensure that there is space in childForId map for a new entry before adding it.

Parameters:
child The child to put into the map
Returns:
Any component that was replaced
	private final Component put(final Component child)
		int index = children_indexOf(child);
		if (index == -1)
			return null;
		else
			return children_set(indexchild);
	}

Parameters:
component Component being removed
	private final void removedComponent(final Component component)
		// Notify Page that component is being removed
		final Page page = component.findPage();
		if (page != null)
			page.componentRemoved(component);
		component.detach();
		// Component is removed
		component.setParent(null);
	}

Renders the next element of markup in the given markup stream.

Parameters:
markupStream The markup stream
	private final void renderNext(final MarkupStream markupStream)
		// Get the current markup element
		final MarkupElement element = markupStream.get();
		// If it a tag like <wicket..> or <span wicket:id="..." >
		if ((element instanceof ComponentTag) && !markupStream.atCloseTag())
			// Get element as tag
			final ComponentTag tag = (ComponentTag)element;
			// Get component id
			final String id = tag.getId();
			// Get the component for the id from the given container
			final Component component = get(id);
			// Failed to find it?
			if (component != null)
				component.render(markupStream);
			else
				// 2rd try: Components like Border and Panel might implement
				// the ComponentResolver interface as well.
				MarkupContainer container = this;
				while (container != null)
					if (container instanceof IComponentResolver)
						if (((IComponentResolver)container).resolve(thismarkupStreamtag))
							return;
					container = container.findParent(MarkupContainer.class);
				// 3rd try: Try application's component resolvers
				final List componentResolvers = getApplication().getPageSettings()
				final Iterator iterator = componentResolvers.iterator();
				while (iterator.hasNext())
					final IComponentResolver resolver = (IComponentResolver)iterator.next();
					if (resolver.resolve(thismarkupStreamtag))
						return;
				if (tag instanceof WicketTag)
					if (((WicketTag)tag).isChildTag())
						markupStream.throwMarkupException("Found " + tag.toString() +
							" but no <wicket:extend>");
					else
						markupStream.throwMarkupException("Failed to handle: " + tag.toString());
				// No one was able to handle the component id
				markupStream.throwMarkupException("Unable to find component with id '" + id +
					"' in " + this + ". This means that you declared wicket:id=" + id +
					" in your markup, but that you either did not add the " +
					"component to your page at all, or that the hierarchy does not match.");
		else
			// Render as raw markup
				.debug("Rendering raw markup");
			markupStream.next();
	}

Get the markup stream for this component.

Returns:
The markup stream for this component, or if it doesn't have one, the markup stream for the nearest parent which does have one
	protected final MarkupStream findMarkupStream()
		// Start here
		MarkupContainer c = this;
		// Walk up hierarchy until markup found
		while (c.getMarkupStream() == null)
			// Check parent
			c = c.getParent();
			// Are we at the top of the hierarchy?
			if (c == null)
				// Failed to find markup stream
				throw new WicketRuntimeException(exceptionMessage("No markup found"));
		return c.getMarkupStream();
	}

Handle the container's body. If your override of this method does not advance the markup stream to the close tag for the openTag, a runtime exception will be thrown by the framework.

Parameters:
markupStream The markup stream
openTag The open tag for the body
	protected void onComponentTagBody(final MarkupStream markupStreamfinal ComponentTag openTag)
		renderComponentTagBody(markupStreamopenTag);
	}

Renders this component. This implementation just calls renderComponent.

Parameters:
markupStream
	protected void onRender(final MarkupStream markupStream)
		renderComponent(markupStream);
	}

Renders this component and all sub-components using the given markup stream.

Parameters:
markupStream The markup stream
	protected void renderAll(final MarkupStream markupStream)
		// Loop through the markup in this container
		while (markupStream.hasMore())
			// Element rendering is responsible for advancing markup stream!
			final int index = markupStream.getCurrentIndex();
			renderNext(markupStream);
			if (index == markupStream.getCurrentIndex())
				markupStream.throwMarkupException("Component at markup stream index " + index +
					" failed to advance the markup stream");
	}

Renders markup for the body of a ComponentTag from the current position in the given markup stream. If the open tag passed in does not require a close tag, nothing happens. Markup is rendered until the closing tag for openTag is reached.

Parameters:
markupStream The markup stream
openTag The open tag
	protected final void renderComponentTagBody(final MarkupStream markupStream,
		final ComponentTag openTag)
		// If the open tag requires a close tag
		boolean render = openTag.requiresCloseTag();
		if (render == false)
			// Tags like <p> do not require a close tag, but they may have.
			render = !openTag.hasNoCloseTag();
		if (render == true)
			// Loop through the markup in this container
			while (markupStream.hasMore() && !markupStream.get().closes(openTag))
				// Render markup element. Doing so must advance the markup
				// stream
				final int index = markupStream.getCurrentIndex();
				renderNext(markupStream);
				if (index == markupStream.getCurrentIndex())
					markupStream.throwMarkupException("Markup element at index " + index +
						" failed to advance the markup stream");
	}

Set markup stream for this container.

Parameters:
markupStream The markup stream
	protected final void setMarkupStream(final MarkupStream markupStream)
		this. = markupStream;
		private ComponentSourceEntry(MarkupContainer containerComponent component,
			IComponentSource componentSource)
			super(containercomponentcomponentSource);
		private static final long serialVersionUID = 1L;
		protected void setChild(MarkupContainer parentint indexComponent child)
			parent.children_set(indexchildfalse);
		for (int i = children_size(); i-- > 0;)
			Object child = children_get(ifalse);
			if (child instanceof Component)
				Component component = (Component)child;
				component.detach();
				if (child instanceof IComponentSourceProvider)
					ComponentSourceEntry entry = new ComponentSourceEntry(thiscomponent,
					children_set(ientryfalse);
				else if (component.isAuto())
		final int size = children_size();
		for (int i = 0; i < sizei++)
			final Component child = children_get(i);
		int size = children_size();
		Component result[] = new Component[size];
		for (int i = 0; i < size; ++i)
			result[i] = children_get(i);
		return result;
		// We need to copy the children list because the children components can
		// modify the hierarchy in their onBeforeRender.
		Component[] children = copyChildren();
		try
			// Loop through child components
			for (int i = 0; i < children.lengthi++)
				// Get next child
				final Component child = children[i];
				// Call begin request on the child
				// We need to check whether the child's wasn't removed from the
				// component in the meanwhile (e.g. from another's child
				// onBeforeRender)
				if (child.getParent() == this)
		catch (RuntimeException ex)
			if (ex instanceof WicketRuntimeException)
				throw ex;
			else
				throw new WicketRuntimeException("Error attaching this container for rendering: " +
					thisex);
		// Loop through child components
		final Iterator iter = iterator();
		while (iter.hasNext())
			// Get next child
			final Component child = (Component)iter.next();
			// Call end request on the child
			child.afterRender();
	}

Returns:
True if this markup container has associated markup
	public boolean hasAssociatedMarkup()
	}

			public Object component(final Component component)
				// Find out if this component can be rendered
				final boolean renderAllowed = component.isActionAuthorized();
				// Authorize rendering
				component.setRenderAllowed(renderAllowed);
		});
New to GrepCode? Check out our FAQ X