javax.servlet.jsp.tagext
Class SimpleTagSupport

java.lang.Object
  |
  +--javax.servlet.jsp.tagext.SimpleTagSupport
All Implemented Interfaces:
JspTag, SimpleTag

public class SimpleTagSupport
extends java.lang.Object
implements SimpleTag

A base class for defining tag handlers implemeting SimpleTag.

The SimpleTagSupport class is a utility class intended to be used as the base class for new simple tag handlers. The SimpleTagSupport class implements the SimpleTag interface and adds additional convenience methods including getter methods for the properties in SimpleTag.

Since:
JSP2.0

Field Summary
protected  JspFragment jspBody
          The body of the tag
protected  JspContext jspContext
          The JSP context for the upcoming tag invocation
 
Constructor Summary
SimpleTagSupport()
           
 
Method Summary
 void doTag()
          Default processing of the tag does nothing.
static JspTag findAncestorWithClass(JspTag from, java.lang.Class klass)
          Find the instance of a given class type that is closest to a given instance.
 JspFragment getJspBody()
          Returns the body passed in by the container via setJspBody
 JspContext getJspContext()
          Returns the page context passed in by the container via setJspContext.
 JspTag getParent()
          Returns the parent of this tag, for collaboration purposes.
 void setJspBody(JspFragment jspBody)
          Stores the provided JspFragment.
 void setJspContext(JspContext pc)
          Stores the provided JSP context in the protected jspContext field.
 void setParent(JspTag parent)
          Sets the parent of this tag, for collaboration purposes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

jspContext

protected JspContext jspContext
The JSP context for the upcoming tag invocation


jspBody

protected JspFragment jspBody
The body of the tag

Constructor Detail

SimpleTagSupport

public SimpleTagSupport()
Method Detail

doTag

public void doTag()
           throws JspException,
                  java.io.IOException
Default processing of the tag does nothing.

Specified by:
doTag in interface SimpleTag
Throws:
JspException - Subclasses can throw JspException to indicate an error occurred while processing this tag.
SkipPageException - If the page that (either directly or indirectly) invoked this tag is to cease evaluation. A Simple Tag Handler generated from a tag file must throw this exception if an invoked Classic Tag Handler returned SKIP_PAGE or if an invoked Simple Tag Handler threw SkipPageException or if an invoked Jsp Fragment threw a SkipPageException.
IOException - Subclasses can throw IOException if there was an error writing to the output stream
java.io.IOException - If there was an error writing to the output stream.
JspException - If an error occurred while processing this tag.
See Also:
SimpleTag.doTag()

setParent

public void setParent(JspTag parent)
Sets the parent of this tag, for collaboration purposes.

Specified by:
setParent in interface SimpleTag
Parameters:
parent - the tag that encloses this tag

getParent

public JspTag getParent()
Returns the parent of this tag, for collaboration purposes.

Specified by:
getParent in interface SimpleTag
Returns:
the parent of this tag

setJspContext

public void setJspContext(JspContext pc)
Stores the provided JSP context in the protected jspContext field.

Specified by:
setJspContext in interface SimpleTag
Parameters:
pc - the page context for this invocation
See Also:
SimpleTag.setJspContext(javax.servlet.jsp.JspContext)

getJspContext

public JspContext getJspContext()
Returns the page context passed in by the container via setJspContext.

Returns:
the page context for this invocation

setJspBody

public void setJspBody(JspFragment jspBody)
Stores the provided JspFragment.

Specified by:
setJspBody in interface SimpleTag
Parameters:
jspBody - The fragment encapsulating the body of this tag, or null if this tag as a body content type of empty.
See Also:
SimpleTag.setJspBody(javax.servlet.jsp.tagext.JspFragment)

getJspBody

public JspFragment getJspBody()
Returns the body passed in by the container via setJspBody

Returns:
the fragment encapsulating the body of this tag, or null if this tag has a body content type of empty.

findAncestorWithClass

public static final JspTag findAncestorWithClass(JspTag from,
                                                 java.lang.Class klass)
Find the instance of a given class type that is closest to a given instance. This method uses the getParent method from the Tag and/or SimpleTag interfaces. This method is used for coordination among cooperating tags.

The current version of the specification only provides one formal way of indicating the observable type of a tag handler: its tag handler implementation class, described in the tag-class subelement of the tag element. This is extended in an informal manner by allowing the tag library author to indicate in the description subelement an observable type. The type should be a subtype of the tag handler implementation class or void. This addititional constraint can be exploited by a specialized container that knows about that specific tag library, as in the case of the JSP standard tag library.

When a tag library author provides information on the observable type of a tag handler, client programmatic code should adhere to that constraint. Specifically, the Class passed to findAncestorWithClass should be a subtype of the observable type.

Parameters:
from - The instance from where to start looking.
klass - The subclass of JspTag or interface to be matched
Returns:
the nearest ancestor that implements the interface or is an instance of the class specified


Copyright © 1999-2002 The Apache Software Foundation. All Rights Reserved.