org.apache.beehive.netui.tags.html
Class FormatNumber

Object
  extended by SimpleTagSupport
      extended by AbstractSimpleTag
          extended by FormatTag
              extended by FormatNumber
All Implemented Interfaces:
JspTag, SimpleTag, INetuiTag

public class FormatNumber
extends FormatTag

A formatter used to format numbers. This formatter uses patterns that conform to java.text.NumberFormat pattern syntax. FormatNumber calls toString() on the object to be formatted to get the value the pattern is applied to. The valid FormatNumber types are:

Example
In this first example, the value "12345678" is formatted to 12,345,678.00.
    <netui:label value="12345678">
        <netui:formatNumber pattern="#,###.00" />
    </netui:label>

In the next sample, the value ".33" is formatted to 33%.

    <netui:label value=".33">
        <netui:formatNumber type="percent" />
    </netui:label>

In the next sample, the value "14.317" is formatted to $14.32.

    <netui:label value="14.317">
        <netui:formatNumber country="US" language="en" type="currency" />
    </netui:label>

Nested Class Summary
static class FormatNumber.NumberFormatter
          Internal FormatTag.Formatter which uses NumberFormat.
 
Nested classes/interfaces inherited from class FormatTag
FormatTag.Formatter
 
Field Summary
protected  String _type
          The type of number format to be used.
 
Fields inherited from class FormatTag
_pattern
 
Constructor Summary
FormatNumber()
           
 
Method Summary
 void doTag()
          Create the internal Formatter instance and perform the formatting.
 String getTagName()
          Return the name of the Tag.
 void setType(String type)
          Sets the type of number format to be used (number, currency, or percent).
 
Methods inherited from class FormatTag
getLocale, setCountry, setLanguage, setPattern
 
Methods inherited from class AbstractSimpleTag
getBufferBody, getHtmlTag, getIdForTagId, getInlineError, getPageContext, getScriptReporter, getUserLocale, hasErrors, registerTagError, registerTagError, reportErrors, rewriteName, setNonEmptyValueAttribute, setRequiredValueAttribute, write
 
Methods inherited from class SimpleTagSupport
findAncestorWithClass, getJspBody, getJspContext, getParent, setJspBody, setJspContext, setParent
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_type

protected String _type
The type of number format to be used.

Constructor Detail

FormatNumber

public FormatNumber()
Method Detail

getTagName

public String getTagName()
Return the name of the Tag.

Specified by:
getTagName in interface INetuiTag
Specified by:
getTagName in class AbstractSimpleTag
Returns:
the name of the tag.

setType

public void setType(String type)
             throws JspException
Sets the type of number format to be used (number, currency, or percent).

Parameters:
type - - the number format type.
Throws:
JspException

doTag

public void doTag()
           throws JspException
Create the internal Formatter instance and perform the formatting.

Specified by:
doTag in interface SimpleTag
Overrides:
doTag in class SimpleTagSupport
Throws:
JspException - if a JSP exception has occurred