net.sourceforge.stripes.tag
Class StripesTagSupport

java.lang.Object
  extended by net.sourceforge.stripes.tag.StripesTagSupport
All Implemented Interfaces:
JspTag, Tag
Direct Known Subclasses:
HtmlTagSupport, LayoutComponentTag, LayoutDefinitionTag, LayoutRenderTag, UseActionBeanTag, VarTagSupport, WizardFieldsTag

public abstract class StripesTagSupport
extends Object
implements Tag

A very basic implementation of the Tag interface that is similar in manner to the standard TagSupport class, but with less clutter.

Author:
Tim Fennell

Field Summary
protected  PageContext pageContext
          Storage for a PageContext during evaluation.
protected  Tag parentTag
          Storage for the parent tag of this tag.
 
Fields inherited from interface javax.servlet.jsp.tagext.Tag
EVAL_BODY_INCLUDE, EVAL_PAGE, SKIP_BODY, SKIP_PAGE
 
Constructor Summary
StripesTagSupport()
           
 
Method Summary
abstract  int doEndTag()
          Abstract method from the Tag interface.
abstract  int doStartTag()
          Abstract method from the Tag interface.
protected  Class<? extends ActionBean> getActionBeanType(Object nameOrClass)
          Helper method that takes an attribute which may be either a String class name or a Class object and returns the Class representing the appropriate ActionBean.
protected  String getActionBeanUrl(Object nameOrClass)
          Similar to the getActionBeanType(Object) method except that instead of returning the Class of ActionBean it returns the URL Binding of the ActionBean.
 PageContext getPageContext()
          Retrieves the pageContext handed to the tag by the container.
 Tag getParent()
          From the Tag interface - allows fetching the parent tag on the JSP.
protected
<T extends Tag>
T
getParentTag(Class<T> tagType)
          Locates the enclosing tag of the type supplied.
protected  Stack<StripesTagSupport> getTagStack()
          Fetches a tag stack that is stored in the request.
 void popPageContextAttributes()
          Attempts to restore page context attributes to their state prior to a call to pushPageContextAttributes().
 void pushPageContextAttributes(Map<String,Object> attributes)
          Pushes new values for the attributes supplied into the page context, preserving the old values so that they can be put back into page context end of the tag's execution (usually in doEndTag).
 void release()
          No-op implementation of release().
 void setPageContext(PageContext pageContext)
          Called by the Servlet container to set the page context on the tag.
 void setParent(Tag tag)
          From the Tag interface - allows the container to set the parent tag on the JSP.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pageContext

protected PageContext pageContext
Storage for a PageContext during evaluation.


parentTag

protected Tag parentTag
Storage for the parent tag of this tag.

Constructor Detail

StripesTagSupport

public StripesTagSupport()
Method Detail

setPageContext

public void setPageContext(PageContext pageContext)
Called by the Servlet container to set the page context on the tag.

Specified by:
setPageContext in interface Tag

getPageContext

public PageContext getPageContext()
Retrieves the pageContext handed to the tag by the container.


setParent

public void setParent(Tag tag)
From the Tag interface - allows the container to set the parent tag on the JSP.

Specified by:
setParent in interface Tag

getParent

public Tag getParent()
From the Tag interface - allows fetching the parent tag on the JSP.

Specified by:
getParent in interface Tag

doStartTag

public abstract int doStartTag()
                        throws JspException
Abstract method from the Tag interface. Abstract because it seems to make the child tags more readable if they implement their own do() methods, even when they just return one of the constants and do nothing else.

Specified by:
doStartTag in interface Tag
Throws:
JspException

doEndTag

public abstract int doEndTag()
                      throws JspException
Abstract method from the Tag interface. Abstract because it seems to make the child tags more readable if they implement their own do() methods, even when they just return one of the constants and do nothing else.

Specified by:
doEndTag in interface Tag
Throws:
JspException

release

public void release()
No-op implementation of release().

Specified by:
release in interface Tag

pushPageContextAttributes

public void pushPageContextAttributes(Map<String,Object> attributes)
Pushes new values for the attributes supplied into the page context, preserving the old values so that they can be put back into page context end of the tag's execution (usually in doEndTag). If this method is called, the tag must also callpopPageContextAttributes().


popPageContextAttributes

public void popPageContextAttributes()
Attempts to restore page context attributes to their state prior to a call to pushPageContextAttributes(). Attributes that had values prior to the execution of this tag have their values restored. Attributes that did not have values are removed from the page context.


getParentTag

protected <T extends Tag> T getParentTag(Class<T> tagType)

Locates the enclosing tag of the type supplied. If no enclosing tag of the type supplied can be found anywhere in the ancestry of this tag, null is returned.

Returns:
T Tag of the type supplied, or null if none can be found

getTagStack

protected Stack<StripesTagSupport> getTagStack()
Fetches a tag stack that is stored in the request. This tag stack is used to help Stripes tags find one another when they are spread across multiple included JSPs and/or tag files - situations in which the usual parent tag relationship fails.


getActionBeanType

protected Class<? extends ActionBean> getActionBeanType(Object nameOrClass)
Helper method that takes an attribute which may be either a String class name or a Class object and returns the Class representing the appropriate ActionBean. If for any reason the Class cannot be determined, or it is not an ActionBean, null will be returned instead.

Parameters:
nameOrClass - either the String FQN of an ActionBean class, or a Class object
Returns:
the appropriate ActionBean class or null

getActionBeanUrl

protected String getActionBeanUrl(Object nameOrClass)
Similar to the getActionBeanType(Object) method except that instead of returning the Class of ActionBean it returns the URL Binding of the ActionBean.

Parameters:
nameOrClass - either the String FQN of an ActionBean class, or a Class object
Returns:
the URL of the appropriate ActionBean class or null


? Copyright 2005-2006, Stripes Development Team.