javax.servlet.jsp.tagext
Class TagSupport

java.lang.Object
  extended by javax.servlet.jsp.tagext.TagSupport
All Implemented Interfaces:
java.io.Serializable, IterationTag, JspTag, Tag
Direct Known Subclasses:
ActionListenerTag, AttributeTag, BodyTagSupport, BundleTag, CatchTag, ChooseTag, ConditionalTagSupport, CoreRedirectTag, CoreUrlTag, CoreWhenTag, FmtRequestEncodingTag, FmtSetTimeZoneTag, FmtTimeZoneTag, FmtTimeZoneTag, ForEachTag, I18NSupport, IfTag, IfTag, IntegerLoopSupportTag, IteratorLoopSupportTag, LoadBundleTag, LoopTagSupport, OtherwiseTag, PhaseListenerTag, RedirectTag, RemoveTag, RequestEncodingTag, SetBundleTag, SetLocaleTag, SetPropertyActionListenerTag, SetTimeZoneTag, SqlDateParamTag, SqlDateParamTag, SqlSetDataSourceTag, SqlSetDataSourceTag, SqlTransactionTag, SqlTransactionTag, UrlTag, ValueChangeListenerTag, WhenTag, XmlForEachTag, XmlIfTag, XmlOutTag, XmlOutTag, XmlSetTag, XmlWhenTag

public class TagSupport
extends java.lang.Object
implements IterationTag, java.io.Serializable

Convenient support class for creating tags which don't analyze their bodies. Normally, tags will extend TagSupport instead of implementing Tag directly.

See Also:
Serialized Form

Field Summary
protected  java.lang.String id
          The value of the "id" attribute for the tag, if specified.
protected  PageContext pageContext
          The owning PageContext.
 
Fields inherited from interface javax.servlet.jsp.tagext.IterationTag
EVAL_BODY_AGAIN
 
Fields inherited from interface javax.servlet.jsp.tagext.Tag
EVAL_BODY_INCLUDE, EVAL_PAGE, SKIP_BODY, SKIP_PAGE
 
Constructor Summary
TagSupport()
          Tags need to implement a zero-arg constructor.
 
Method Summary
 int doAfterBody()
          Processed to check if the tag should loop.
 int doEndTag()
          Processed at the end of the tag.
 int doStartTag()
          Processed at the beginning of the tag.
static Tag findAncestorWithClass(Tag tag, java.lang.Class cl)
          Finds an ancestor of a tag matching the class.
 java.lang.String getId()
          Sets the id attribute.
 Tag getParent()
          Returns the tag's parent.
 java.lang.Object getValue(java.lang.String name)
          Returns an attribute from the tag.
 java.util.Enumeration<java.lang.String> getValues()
          Enumerates the tag's attributes.
 void release()
          Cleans the tag after it completes.
 void removeValue(java.lang.String name)
          Removes a value from the tag.
 void setId(java.lang.String id)
          Sets the id attribute.
 void setPageContext(PageContext page)
          Stores the page context for the JSP page.
 void setParent(Tag parent)
          If the tag is contained in another tag, this sets the parent.
 void setValue(java.lang.String name, java.lang.Object value)
          Sets the value for a tag attribute.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

id

protected java.lang.String id
The value of the "id" attribute for the tag, if specified.


pageContext

protected PageContext pageContext
The owning PageContext.

Constructor Detail

TagSupport

public TagSupport()
Tags need to implement a zero-arg constructor.

Method Detail

doStartTag

public int doStartTag()
               throws JspException
Processed at the beginning of the tag.

The default behavior returns SKIP_BODY to skip the tag's body.

Specified by:
doStartTag in interface Tag
Returns:
SKIP_BODY to ignore the body and EVAL_BODY_INCLUDE to evaluate the body.
Throws:
JspException

doAfterBody

public int doAfterBody()
                throws JspException
Processed to check if the tag should loop. The default behavior returns SKIP_BODY so it does not loop.

Specified by:
doAfterBody in interface IterationTag
Returns:
EVAL_BODY_AGAIN to repeat the body or SKIP_BODY to stop.
Throws:
JspException

doEndTag

public int doEndTag()
             throws JspException
Processed at the end of the tag. The default behavior continues with the rest of the JSP.

Specified by:
doEndTag in interface Tag
Returns:
EVAL_PAGE to continue the page SKIP_PAGE to stop.
Throws:
JspException

setId

public void setId(java.lang.String id)
Sets the id attribute.


getId

public java.lang.String getId()
Sets the id attribute.


setPageContext

public void setPageContext(PageContext page)
Stores the page context for the JSP page.

Specified by:
setPageContext in interface Tag

setParent

public void setParent(Tag parent)
If the tag is contained in another tag, this sets the parent.

Specified by:
setParent in interface Tag
Parameters:
parent - the tag to be used as a parent.

getParent

public Tag getParent()
Returns the tag's parent.

Specified by:
getParent in interface Tag

findAncestorWithClass

public static final Tag findAncestorWithClass(Tag tag,
                                              java.lang.Class cl)
Finds an ancestor of a tag matching the class. The search is strict, i.e. only parents will be searched, not the tag itself.

Parameters:
tag - child tag to start searching.
cl - the class that the tag should implement.
Returns:
the matching tag or null.

getValue

public java.lang.Object getValue(java.lang.String name)
Returns an attribute from the tag.


getValues

public java.util.Enumeration<java.lang.String> getValues()
Enumerates the tag's attributes.


removeValue

public void removeValue(java.lang.String name)
Removes a value from the tag.


setValue

public void setValue(java.lang.String name,
                     java.lang.Object value)
Sets the value for a tag attribute.

Parameters:
name - the name of the attribute.
value - the new value for the attribute.

release

public void release()
Cleans the tag after it completes.

Specified by:
release in interface Tag