Class ComponentTag

java.lang.Object
org.apache.wicket.markup.MarkupElement
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 Details

  • Constructor Details

    • ComponentTag

      public ComponentTag(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

      Constructor
      Parameters:
      tag - The ComponentTag tag which this wicket tag is based upon.
  • Method Details

    • 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 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:
    • getAttribute

      public final String getAttribute(String name)
      A convenient method. The same as getAttributes().getString(name)
      Parameters:
      name -
      Returns:
      The attributes value
    • getId

      public final 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 String getName()
      Returns:
      The tag's name
    • getNamespace

      public final 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:
    • 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:
    • isOpen

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

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

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

      public final boolean isOpenClose(String id)
      Parameters:
      id - Required component id
      Returns:
      True if this tag is an openclose tag with the given component id
      See Also:
    • 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

      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(String key, boolean value)
      Parameters:
      key - The key
      value - The value
      See Also:
    • put

      public final void put(String key, int value)
      Parameters:
      key - The key
      value - The value
      See Also:
    • put

      public final void put(String key, CharSequence value)
      Parameters:
      key - The key
      value - The value
      See Also:
    • putInternal

      public final void putInternal(String key, CharSequence value)
      THIS METHOD IS NOT PART OF THE PUBLIC API, DO NOT CALL IT
      Parameters:
      key - The key
      value - The value
      See Also:
    • append

      public final void append(String key, CharSequence value, 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(String key, StringValue value)
      Parameters:
      key - The key
      value - The value
      See Also:
    • putAll

      public final void putAll(Map<String,Object> map)
      Parameters:
      map - a key/value map
      See Also:
    • remove

      public final void remove(String key)
      Parameters:
      key - The key to remove
      See Also:
    • 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(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(String name)
      Parameters:
      name - New tag name
      See Also:
    • setNamespace

      public final void setNamespace(String namespace)
      Parameters:
      namespace - New tag name namespace
      See Also:
    • 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:
      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
    • writeSyntheticCloseTag

      public final void writeSyntheticCloseTag(Response response)
      Writes the synthetic close tag for this tag to the response
      Parameters:
      response - The response to write to
    • toCharSequence

      Specified by:
      toCharSequence in class MarkupElement
      Returns:
      Gets the charsequence representation of this element
      See Also:
    • toString

      public final String toString()
      Converts this object to a string representation.
      Overrides:
      toString in class Object
      Returns:
      String version of this object
    • writeOutput

      public final void writeOutput(Response response, boolean stripWicketAttributes, 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
    • toUserDebugString

      public final 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 -
    • setContainsWicketId

      public void setContainsWicketId(boolean containsWicketId)
      Sets the flag to indicate if the current tag contains a child or a descendant with the "wicket:id" attribute.
      Parameters:
      containsWicketId -
    • containsWicketId

      public boolean containsWicketId()
      Says if the current tag contains a child or a descendant with the "wicket:id" attribute.
      Returns:
      true if the current tag contains a child or a descendant with the "wicket:id" attribute.
    • getMarkupClass

      public 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(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:
    • 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 Object getUserData(String key)
      Gets userData.
      Parameters:
      key - The key to store and retrieve the value
      Returns:
      userData
    • setUserData

      public void setUserData(String key, 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 markup stream
    • getAutoComponentFactory

    • setAutoComponentFactory

      public void setAutoComponentFactory(ComponentTag.IAutoComponentFactory autoComponentFactory)