org.sf.charttaglibs.utils
Class TagUtils

java.lang.Object
  extended byorg.sf.charttaglibs.utils.TagUtils

public class TagUtils
extends java.lang.Object

Provides helper methods for JSP tags.


Field Summary
private static TagUtils instance
          The Singleton instance.
private static Message messages
          The message resources for this package.
private static java.util.Map scopes
          Maps lowercase JSP scope names to their PageContext integer constant values.
 
Constructor Summary
protected TagUtils()
          Constructor for TagUtils.
 
Method Summary
static TagUtils getInstance()
          Returns the Singleton instance of TagUtils.
 int getScope(java.lang.String scopeName)
          Converts the scope name into its corresponding PageContext constant value.
 java.lang.Object lookup(javax.servlet.jsp.PageContext pageContext, java.lang.String name, java.lang.String scopeName)
          Locate and return the specified bean, from an optionally specified scope, in the specified page context.
 java.lang.Object lookup(javax.servlet.jsp.PageContext pageContext, java.lang.String name, java.lang.String property, java.lang.String scope)
          Locate and return the specified property of the specified bean, from an optionally specified scope, in the specified page context.
 void write(javax.servlet.jsp.PageContext pageContext, java.lang.String text)
          Write the specified text as the response to the writer associated with this page.
 void writePrevious(javax.servlet.jsp.PageContext pageContext, java.lang.String text)
          Write the specified text as the response to the writer associated with the body content for the tag within which we are currently nested.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

instance

private static final TagUtils instance
The Singleton instance.


messages

private static final Message messages
The message resources for this package.


scopes

private static final java.util.Map scopes
Maps lowercase JSP scope names to their PageContext integer constant values.

Constructor Detail

TagUtils

protected TagUtils()
Constructor for TagUtils.

Method Detail

getInstance

public static TagUtils getInstance()
Returns the Singleton instance of TagUtils.


getScope

public int getScope(java.lang.String scopeName)
             throws javax.servlet.jsp.JspException
Converts the scope name into its corresponding PageContext constant value.

Parameters:
scopeName - Can be "page", "request", "session", or "application" in any case.
Returns:
The constant representing the scope (ie. PageContext.REQUEST_SCOPE).
Throws:
javax.servlet.jsp.JspException - if the scopeName is not a valid name.

lookup

public java.lang.Object lookup(javax.servlet.jsp.PageContext pageContext,
                               java.lang.String name,
                               java.lang.String scopeName)
                        throws javax.servlet.jsp.JspException
Locate and return the specified bean, from an optionally specified scope, in the specified page context. If no such bean is found, return null instead. If an exception is thrown, it will have already been saved via a call to saveException().

Parameters:
pageContext - Page context to be searched
name - Name of the bean to be retrieved
scopeName - Scope to be searched (page, request, session, application) or null to use findAttribute() instead
Returns:
JavaBean in the specified page context
Throws:
javax.servlet.jsp.JspException - if an invalid scope name is requested

lookup

public java.lang.Object lookup(javax.servlet.jsp.PageContext pageContext,
                               java.lang.String name,
                               java.lang.String property,
                               java.lang.String scope)
                        throws javax.servlet.jsp.JspException
Locate and return the specified property of the specified bean, from an optionally specified scope, in the specified page context. If an exception is thrown, it will have already been saved via a call to saveException().

Parameters:
pageContext - Page context to be searched
name - Name of the bean to be retrieved
property - Name of the property to be retrieved, or null to retrieve the bean itself
scope - Scope to be searched (page, request, session, application) or null to use findAttribute() instead
Returns:
property of specified JavaBean
Throws:
javax.servlet.jsp.JspException - if an invalid scope name is requested
javax.servlet.jsp.JspException - if the specified bean is not found
javax.servlet.jsp.JspException - if accessing this property causes an IllegalAccessException, IllegalArgumentException, InvocationTargetException, or NoSuchMethodException

write

public void write(javax.servlet.jsp.PageContext pageContext,
                  java.lang.String text)
           throws javax.servlet.jsp.JspException
Write the specified text as the response to the writer associated with this page. WARNING - If you are writing body content from the doAfterBody() method of a custom tag class that implements BodyTag, you should be calling writePrevious() instead.

Parameters:
pageContext - The PageContext object for this page
text - The text to be written
Throws:
javax.servlet.jsp.JspException - if an input/output error occurs (already saved)

writePrevious

public void writePrevious(javax.servlet.jsp.PageContext pageContext,
                          java.lang.String text)
                   throws javax.servlet.jsp.JspException
Write the specified text as the response to the writer associated with the body content for the tag within which we are currently nested.

Parameters:
pageContext - The PageContext object for this page
text - The text to be written
Throws:
javax.servlet.jsp.JspException - if an input/output error occurs (already saved)