Class 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
    • Constructor Detail

      • 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

        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
      • 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
      • 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
      • 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()
      • 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
      • isOpen

        public final boolean isOpen()
        Returns:
        True if this tag is an open tag
        See Also:
        XmlTag.isOpen()
      • 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:
        XmlTag.isOpen()
      • 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:
        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.
      • 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
      • 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.
      • 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
      • 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
      • 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 ComponentgetMarkupClass()
        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
      • 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