net.sourceforge.stripes.tag
Class FormatTag

java.lang.Object
  extended by net.sourceforge.stripes.tag.StripesTagSupport
      extended by net.sourceforge.stripes.tag.VarTagSupport
          extended by net.sourceforge.stripes.tag.FormatTag
All Implemented Interfaces:
JspTag, Tag

public class FormatTag
extends VarTagSupport

This tag accepts an object and formats it using an appropriate Formatter. The resulting String can be assigned in the page, request, session or application scopes by using "var" and "scope" or it can be written directly to the JSP output.

Since:
Stripes 1.5
Author:
Ben Gunter

Field Summary
 
Fields inherited from class net.sourceforge.stripes.tag.VarTagSupport
scope, var
 
Fields inherited from class net.sourceforge.stripes.tag.StripesTagSupport
pageContext, parentTag
 
Fields inherited from interface javax.servlet.jsp.tagext.Tag
EVAL_BODY_INCLUDE, EVAL_PAGE, SKIP_BODY, SKIP_PAGE
 
Constructor Summary
FormatTag()
           
 
Method Summary
 int doEndTag()
          Abstract method from the Tag interface.
 int doStartTag()
          Abstract method from the Tag interface.
protected  String format(Object value)
          Attempts to format an object using an appropriate Formatter.
 String getFormatPattern()
          Get the format pattern
 String getFormatType()
          Get the format type
 Object getValue()
          Get the object to be formatted
 void setFormatPattern(String formatPattern)
          Set the format pattern
 void setFormatType(String formatType)
          Set the format type
 void setValue(Object value)
          Set the object to be formatted
protected  void writeOut(Object value)
          Calls format(Object) and writes the resulting String to the JSP output.
 
Methods inherited from class net.sourceforge.stripes.tag.VarTagSupport
export, getScope, getVar, setScope, setVar
 
Methods inherited from class net.sourceforge.stripes.tag.StripesTagSupport
getActionBeanType, getActionBeanUrl, getPageContext, getParent, getParentTag, getTagStack, popPageContextAttributes, pushPageContextAttributes, release, setPageContext, setParent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FormatTag

public FormatTag()
Method Detail

getFormatPattern

public String getFormatPattern()
Get the format pattern


setFormatPattern

public void setFormatPattern(String formatPattern)
Set the format pattern


getFormatType

public String getFormatType()
Get the format type


setFormatType

public void setFormatType(String formatType)
Set the format type


getValue

public Object getValue()
Get the object to be formatted


setValue

public void setValue(Object value)
Set the object to be formatted


format

protected String format(Object value)
Attempts to format an object using an appropriate Formatter. If no formatter is available for the object, then this method will call toString() on the object. A null value will be formatted as an empty string.

Parameters:
value - the object to be formatted
Returns:
the formatted value

writeOut

protected void writeOut(Object value)
                 throws JspException
Calls format(Object) and writes the resulting String to the JSP output.

Parameters:
value - the object to be formatted and written
Throws:
JspException

doStartTag

public int doStartTag()
               throws JspException
Description copied from class: StripesTagSupport
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
Specified by:
doStartTag in class StripesTagSupport
Throws:
JspException

doEndTag

public int doEndTag()
             throws JspException
Description copied from class: StripesTagSupport
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
Specified by:
doEndTag in class StripesTagSupport
Throws:
JspException


? Copyright 2005-2006, Stripes Development Team.