org.apache.wicket.markup
Class ComponentTag

java.lang.Object
  extended by org.apache.wicket.markup.MarkupElement
      extended by org.apache.wicket.markup.ComponentTag
Direct Known Subclasses:
WicketTag

public class ComponentTag
extends MarkupElement

A subclass of MarkupElement which represents a "significant" markup tag, such as a component open tag. Insignificant markup tags (those which are merely concerned with markup formatting operations and do not denote components or component nesting) are coalesced into instances of RawMarkup (also a subclass of MarkupElement).

Author:
Jonathan Locke

Field Summary
static int RENDER_RAW
          Render the tag as RawMarkup even if no Component can be found
protected  XmlTag xmlTag
          The underlying xml tag
 
Constructor Summary
ComponentTag(ComponentTag tag)
          Constructor
ComponentTag(java.lang.String name, XmlTag.TagType type)
          Automatically create a XmlTag, assign the name and the type, and construct a ComponentTag based on this XmlTag.
ComponentTag(XmlTag tag)
          Construct.
 
Method Summary
 void addBehavior(Behavior behavior)
          Adds a behavior to this component tag.
 void append(java.lang.String key, java.lang.CharSequence value, java.lang.String separator)
          Appends specified value to the attribute
 boolean closes(MarkupElement open)
          Gets whether this tag closes the provided open tag.
 void enableAutolink(boolean autolink)
          If autolink is set to true, href attributes will automatically be converted into Wicket bookmarkable URLs.
 boolean equalTo(MarkupElement element)
          This is not an implementation of equals because we don't care about hashCodes for MarkupElements yet.
 java.lang.String getAttribute(java.lang.String name)
          A convenient method.
 IValueMap getAttributes()
           
 java.util.Iterator<? extends Behavior> getBehaviors()
           
 boolean getFlag(int flag)
          THIS METHOD IS NOT PART OF THE WICKET PUBLIC API.
 java.lang.String getId()
          Get the tag's component id
 int getLength()
          Gets the length of the tag in characters.
 java.lang.Class<? extends Component> getMarkupClass()
          In case of inherited markup, the base and the extended markups are merged and the information about the tags origin is lost.
 java.lang.String getName()
           
 java.lang.String getNamespace()
           
 ComponentTag getOpenTag()
          If set, return the corresponding open tag (ComponentTag).
 int getPos()
           
 java.lang.String getString(java.lang.String name)
          Deprecated. since 1.5
 XmlTag.TagType getType()
           
 java.lang.Object getUserData(java.lang.String key)
          Gets userData.
 XmlTag getXmlTag()
           
 boolean hasBehaviors()
           
 boolean hasNoCloseTag()
           
 boolean isAutoComponentTag()
           
 boolean isAutolinkEnabled()
          True if autolink is enabled and the tag contains a href attribute.
 boolean isClose()
           
 boolean isIgnore()
          Gets ignore.
 boolean isOpen()
           
 boolean isOpen(java.lang.String id)
           
 boolean isOpenClose()
           
 boolean isOpenClose(java.lang.String id)
           
 void makeImmutable()
          Makes this tag object immutable by making the attribute map unmodifiable.
 ComponentTag mutable()
          Gets this tag if it is already mutable, or a mutable copy of this tag if it is immutable.
 void onBeforeRender(Component component, MarkupStream markupStream)
          For subclasses to override.
 void put(java.lang.String key, boolean value)
           
 void put(java.lang.String key, java.lang.CharSequence value)
           
 void put(java.lang.String key, int value)
           
 void put(java.lang.String key, StringValue value)
           
 void putAll(java.util.Map<java.lang.String,java.lang.Object> map)
           
 void putInternal(java.lang.String key, java.lang.CharSequence value)
          THIS METHOD IS NOT PART OF THE PUBLIC API, DO NOT CALL IT
 void remove(java.lang.String key)
           
 boolean requiresCloseTag()
          Gets whether this tag does not require a closing tag.
 void setAutoComponentTag(boolean auto)
           
 void setFlag(int flag, boolean set)
          THIS METHOD IS NOT PART OF THE WICKET PUBLIC API.
 void setHasNoCloseTag(boolean hasNoCloseTag)
          True if the HTML tag (e.g.
 void setId(java.lang.String id)
          Set the component's id.
 void setIgnore(boolean ignore)
          Sets ignore.
<C extends Component>
void
setMarkupClass(java.lang.Class<C> wicketHeaderClass)
          Set the class of wicket component which contains the wicket:head tag.
 void setModified(boolean modified)
          Manually mark the ComponentTag being modified.
 void setName(java.lang.String name)
           
 void setNamespace(java.lang.String namespace)
           
 void setOpenTag(ComponentTag tag)
          Assuming this is a close tag, assign it's corresponding open tag.
 void setType(XmlTag.TagType type)
          THIS METHOD IS NOT PART OF THE WICKET PUBLIC API.
 void setUserData(java.lang.String key, java.lang.Object value)
          Sets userData.
 java.lang.CharSequence syntheticCloseTagString()
           
 java.lang.CharSequence toCharSequence()
           
 java.lang.String toString()
          Converts this object to a string representation.
 java.lang.String toUserDebugString()
          Converts this object to a string representation including useful information for debugging
 void writeOutput(Response response, boolean stripWicketAttributes, java.lang.String namespace)
          Write the tag to the response
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

RENDER_RAW

public static final int RENDER_RAW
Render the tag as RawMarkup even if no Component can be found

See Also:
Constant Field Values

xmlTag

protected final XmlTag xmlTag
The underlying xml tag

Constructor Detail

ComponentTag

public ComponentTag(java.lang.String name,
                    XmlTag.TagType type)
Automatically create a XmlTag, assign the name and the type, and construct a ComponentTag based on this XmlTag.

Parameters:
name - The name of html tag
type - The type of tag

ComponentTag

public ComponentTag(XmlTag tag)
Construct.

Parameters:
tag - The underlying xml tag

ComponentTag

public ComponentTag(ComponentTag tag)
Constructor

Parameters:
tag - The ComponentTag tag which this wicket tag is based upon.
Method Detail

setFlag

public final void setFlag(int flag,
                          boolean set)
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT USE IT!

Parameters:
flag - The flag to set
set - True to turn the flag on, false to turn it off

getFlag

public final boolean getFlag(int flag)
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT USE IT!

Parameters:
flag - The flag to test
Returns:
True if the flag is set

addBehavior

public final void addBehavior(Behavior behavior)
Adds a behavior to this component tag.

Parameters:
behavior -

hasBehaviors

public final boolean hasBehaviors()
Returns:
true if this tag has any behaviors added, false otherwise

getBehaviors

public final java.util.Iterator<? extends Behavior> getBehaviors()
Returns:
read only iterator over added behaviors

closes

public final boolean closes(MarkupElement open)
Gets whether this tag closes the provided open tag.

Overrides:
closes in class MarkupElement
Parameters:
open - The open tag
Returns:
True if this tag closes the given open tag

enableAutolink

public final void enableAutolink(boolean autolink)
If autolink is set to true, href attributes will automatically be converted into Wicket bookmarkable URLs.

Parameters:
autolink - enable/disable automatic href conversion

getAttributes

public final IValueMap getAttributes()
Returns:
The tag#s attributes
See Also:
XmlTag.getAttributes()

getAttribute

public final java.lang.String getAttribute(java.lang.String name)
A convenient method. The same as getAttributes().getString(name)

Parameters:
name -
Returns:
The attributes value

getString

@Deprecated
public final java.lang.String getString(java.lang.String name)
Deprecated. since 1.5

Please use getAttribute(String) instead

Parameters:
name -
Returns:
The attribute

getId

public final java.lang.String getId()
Get the tag's component id

Returns:
The component id attribute of this tag

getLength

public final int getLength()
Gets the length of the tag in characters.

Returns:
The tag's length

getName

public final java.lang.String getName()
Returns:
The tag's name

getNamespace

public final java.lang.String getNamespace()
Returns:
The tag's namespace

getOpenTag

public final ComponentTag getOpenTag()
If set, return the corresponding open tag (ComponentTag).

Returns:
The corresponding open tag

getPos

public final int getPos()
Returns:
Tag location (index in input string)
See Also:
XmlTag.getPos()

getType

public final XmlTag.TagType getType()
Returns:
the tag type (OPEN, CLOSE or OPEN_CLOSE).

isAutolinkEnabled

public final boolean isAutolinkEnabled()
True if autolink is enabled and the tag contains a href attribute.

Returns:
True, if the href contained should automatically be converted

isClose

public final boolean isClose()
Returns:
True if this tag is a close tag
See Also:
XmlTag.isClose()

isOpen

public final boolean isOpen()
Returns:
True if this tag is an open tag
See Also:
XmlTag.isOpen()

isOpen

public final boolean isOpen(java.lang.String id)
Parameters:
id - Required component id
Returns:
True if this tag is an open tag with the given component name
See Also:
XmlTag.isOpen()

isOpenClose

public final boolean isOpenClose()
Returns:
True if this tag is an open and a close tag
See Also:
XmlTag.isOpenClose()

isOpenClose

public final boolean isOpenClose(java.lang.String id)
Parameters:
id - Required component id
Returns:
True if this tag is an openclose tag with the given component id
See Also:
XmlTag.isOpenClose()

makeImmutable

public final void makeImmutable()
Makes this tag object immutable by making the attribute map unmodifiable. Immutable tags cannot be made mutable again. They can only be copied into new mutable tag objects.


mutable

public ComponentTag mutable()
Gets this tag if it is already mutable, or a mutable copy of this tag if it is immutable.

Returns:
This tag if it is already mutable, or a mutable copy of this tag if it is immutable.

put

public final void put(java.lang.String key,
                      boolean value)
Parameters:
key - The key
value - The value
See Also:
XmlTag.put(String, boolean)

put

public final void put(java.lang.String key,
                      int value)
Parameters:
key - The key
value - The value
See Also:
XmlTag.put(String, int)

put

public final void put(java.lang.String key,
                      java.lang.CharSequence value)
Parameters:
key - The key
value - The value
See Also:
XmlTag.put(String, CharSequence)

putInternal

public final void putInternal(java.lang.String key,
                              java.lang.CharSequence value)
THIS METHOD IS NOT PART OF THE PUBLIC API, DO NOT CALL IT

Parameters:
key - The key
value - The value
See Also:
XmlTag.put(String, CharSequence)

append

public final void append(java.lang.String key,
                         java.lang.CharSequence value,
                         java.lang.String separator)
Appends specified value to the attribute

Parameters:
key - The key
value - The value
separator - The separator used to append the value

put

public final void put(java.lang.String key,
                      StringValue value)
Parameters:
key - The key
value - The value
See Also:
XmlTag.put(String, StringValue)

putAll

public final void putAll(java.util.Map<java.lang.String,java.lang.Object> map)
Parameters:
map - a key/value map
See Also:
XmlTag.putAll(Map)

remove

public final void remove(java.lang.String key)
Parameters:
key - The key to remove
See Also:
XmlTag.remove(String)

requiresCloseTag

public final boolean requiresCloseTag()
Gets whether this tag does not require a closing tag.

Returns:
True if this tag does not require a closing tag

setId

public final void setId(java.lang.String id)
Set the component's id. The value is usually taken from the tag's id attribute, e.g. wicket:id="componentId".

Parameters:
id - The component's id assigned to the tag.

setName

public final void setName(java.lang.String name)
Parameters:
name - New tag name
See Also:
XmlTag.setName(String)

setNamespace

public final void setNamespace(java.lang.String namespace)
Parameters:
namespace - New tag name namespace
See Also:
XmlTag.setNamespace(String)

setOpenTag

public final void setOpenTag(ComponentTag tag)
Assuming this is a close tag, assign it's corresponding open tag.

Parameters:
tag - the open-tag
Throws:
java.lang.RuntimeException - if 'this' is not a close tag

setType

public final void setType(XmlTag.TagType type)
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT CALL IT.

Parameters:
type - The new type

syntheticCloseTagString

public final java.lang.CharSequence syntheticCloseTagString()
Returns:
A synthetic close tag for this tag

toCharSequence

public java.lang.CharSequence toCharSequence()
Specified by:
toCharSequence in class MarkupElement
Returns:
Gets the charsequence representation of this element
See Also:
MarkupElement.toCharSequence()

toString

public final java.lang.String toString()
Converts this object to a string representation.

Overrides:
toString in class java.lang.Object
Returns:
String version of this object

writeOutput

public final void writeOutput(Response response,
                              boolean stripWicketAttributes,
                              java.lang.String namespace)
Write the tag to the response

Parameters:
response - The response to write to
stripWicketAttributes - if true, wicket:id are removed from output
namespace - Wicket's namespace to use
escapeAttributeValue -

toUserDebugString

public final java.lang.String toUserDebugString()
Converts this object to a string representation including useful information for debugging

Specified by:
toUserDebugString in class MarkupElement
Returns:
String version of this object

getXmlTag

public final XmlTag getXmlTag()
Returns:
Returns the underlying xml tag.

setModified

public final void setModified(boolean modified)
Manually mark the ComponentTag being modified. Flagging the tag being modified does not happen automatically.

Parameters:
modified -

hasNoCloseTag

public boolean hasNoCloseTag()
Returns:
True if the HTML tag (e.g. br) has no close tag

setHasNoCloseTag

public void setHasNoCloseTag(boolean hasNoCloseTag)
True if the HTML tag (e.g. br) has no close tag

Parameters:
hasNoCloseTag -

getMarkupClass

public java.lang.Class<? extends Component> getMarkupClass()
In case of inherited markup, the base and the extended markups are merged and the information about the tags origin is lost. In some cases like wicket:head and wicket:link this information however is required.

Returns:
wicketHeaderClass

setMarkupClass

public <C extends Component> void setMarkupClass(java.lang.Class<C> wicketHeaderClass)
Set the class of wicket component which contains the wicket:head tag.

Type Parameters:
C -
Parameters:
wicketHeaderClass - wicketHeaderClass

equalTo

public boolean equalTo(MarkupElement element)
Description copied from class: MarkupElement
This is not an implementation of equals because we don't care about hashCodes for MarkupElements yet. Also, this method only compares the namespace, name and attributes of the given MarkupElements.

Specified by:
equalTo in class MarkupElement
Parameters:
element - The markup element to compare with
Returns:
True if the other element equals this one
See Also:
MarkupElement.equalTo(org.apache.wicket.markup.MarkupElement)

isIgnore

public boolean isIgnore()
Gets ignore.

Returns:
If true than MarkupParser will remove it from the markup

setIgnore

public void setIgnore(boolean ignore)
Sets ignore.

Parameters:
ignore - If true than MarkupParser will remove it from the markup

isAutoComponentTag

public boolean isAutoComponentTag()
Returns:
True, if wicket:id has been automatically created (internal component)

setAutoComponentTag

public void setAutoComponentTag(boolean auto)
Parameters:
auto - True, if wicket:id has been automatically created (internal component)

getUserData

public java.lang.Object getUserData(java.lang.String key)
Gets userData.

Parameters:
key - The key to store and retrieve the value
Returns:
userData

setUserData

public void setUserData(java.lang.String key,
                        java.lang.Object value)
Sets userData.

Parameters:
key - The key to store and retrieve the value
value - The user specific value to store

onBeforeRender

public void onBeforeRender(Component component,
                           MarkupStream markupStream)
For subclasses to override. Gets called just before a Component gets rendered. It is guaranteed that the markupStream is set on the Component and determineVisibility is not yet called.

Parameters:
component - The component that is about to be rendered
markupStream - The current amrkup stream


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