BEA NetUI tags and APIs are included for backward compatibility only. For new applications, use the Beehive tags and APIs.

com.bea.wlw.netui.tags.html
Class FormatNumber

java.lang.Object
  extended by javax.servlet.jsp.tagext.TagSupport
      extended by javax.servlet.jsp.tagext.BodyTagSupport
          extended by com.bea.wlw.netui.tags.AbstractBaseTag
              extended by com.bea.wlw.netui.tags.html.FormatTag
                  extended by com.bea.wlw.netui.tags.html.FormatNumber
All Implemented Interfaces:
HtmlConstants, Serializable, javax.servlet.jsp.tagext.BodyTag, javax.servlet.jsp.tagext.IterationTag, javax.servlet.jsp.tagext.JspTag, javax.servlet.jsp.tagext.Tag

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:

Attribute Descriptions
AttributeRequiredRuntime Expression EvaluationData Bindable
countryNoNoNo
The country code used to determine the locale.
languageNoNoNo
The language code used to determine the locale.
patternNoNoRead Only
The NumberFormat pattern used to format this number.
typeNoNoNo
The type of the format to apply (number, currency, or percent).

See Also:
FormatDate, FormatString, java.text.NumberFormat, Serialized Form
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>

Code Sample

[BEA_HOME]/weblogic81/samples/workshop/SamplesApp/WebApp/tagSamples/netui/formatTags/index.jsp
Beadoc.see:
<netui:format...> Tag Samples
Beadoc.tagdescription:
A tag used to format numbers.

The <netui:formatNumber> tag formats the output of its parent tag. For example:

    <netui:label value="{price}">
        <netui:formatNumber country="FR" language="fr" type="currency" />
    </netui:label>

The pattern attribute conforms to java.text.DecimalFormat pattern syntax.

The pattern attribute uses the comma as a grouping separater. If many different grouping sizes are specified in one pattern, the right-most grouping interval will be used throughout; the other grouping intervals will be ignored. For example, the following format patterns all produce the same result. If the number to format is 123456789, each will produce 123,456,789.

  • pattern="#,##,###,###"
  • pattern="######,###"
  • pattern="##,####,###"

The type attribute specifies three common kinds of formatting to be applied to the number. The valid values for the type attribute are:

  • number
  • currency
  • percent

The country attribute takes an upper-case, two-letter code as defined by ISO-3166. For a list of country codes see ISO-3166 Country Codes

The language attribute takes a lower-case, two-letter code as defined by ISO-639. For a list of ISO-639 language codes see ISO-639 Language Codes


Nested Class Summary
static class FormatNumber.NumberFormatter
          Internal FormatTag.Formatter which uses NumberFormat.
 
Nested classes/interfaces inherited from class com.bea.wlw.netui.tags.html.FormatTag
FormatTag.Formatter
 
Field Summary
protected  String type
          The type of number format to be used.
 
Fields inherited from class com.bea.wlw.netui.tags.html.FormatTag
pattern, patternValue
 
Fields inherited from class com.bea.wlw.netui.tags.AbstractBaseTag
ATTR_GENERAL, ATTR_GENERAL_EXPRESSION, ATTR_JAVASCRIPT, ATTR_STYLE, JAVASCRIPT_STATUS, NETUI_UNIQUE_CNT
 
Fields inherited from class javax.servlet.jsp.tagext.BodyTagSupport
bodyContent
 
Fields inherited from class javax.servlet.jsp.tagext.TagSupport
id, pageContext
 
Fields inherited from interface com.bea.wlw.netui.tags.html.HtmlConstants
ACCEPT, ACCESSKEY, ACTION, ALIGN, ALINK, ALT, ANCHOR, BACKGROUND, BASE, BGCOLOR, BODY, BORDER, BR, CAPTION, CELLPADDING, CELLSPACING, CHAR, CHAROFF, CHARSET, CHECKED, CLASS, COLS, COORDS, DIR, DISABLED, DIV, ENCTYPE, FOR, FORM, FORM_GET, FORM_POST, FRAME, HEIGHT, HREF, HREFLANG, HSPACE, HTML, ID, IMAGE, INPUT, INPUT_BUTTON, INPUT_CHECKBOX, INPUT_FILE, INPUT_HIDDEN, INPUT_IMAGE, INPUT_PASSWORD, INPUT_RADIO, INPUT_RESET, INPUT_SUBMIT, INPUT_TEXT, ISMAP, LABEL, LANG, LINK, LONGDESC, MAXLENGTH, METHOD, NAME, ONBLUR, ONCHANGE, ONCLICK, ONDBLCLICK, ONFOCUS, ONKEYDOWN, ONKEYPRESS, ONKEYUP, ONLOAD, ONMOUSEDOWN, ONMOUSEMOVE, ONMOUSEOUT, ONMOUSEOVER, ONMOUSEUP, ONRESET, ONSELECT, ONSUBMIT, ONUNLOAD, OPTION, READONLY, REL, REV, ROWS, RULES, SELECT, SHAPE, SIZE, SPAN, SRC, STYLE, SUMMARY, TABINDEX, TABLE, TARGET, TD, TEXT, TEXTAREA, TITLE, TR, TYPE, USEMAP, VALIGN, VALUE, VLINK, VSPACE, WIDTH
 
Fields inherited from interface javax.servlet.jsp.tagext.BodyTag
EVAL_BODY_BUFFERED, EVAL_BODY_TAG
 
Fields inherited from interface javax.servlet.jsp.tagext.IterationTag
EVAL_BODY_AGAIN
 
Fields inherited from interface javax.servlet.jsp.tagext.Tag
EVAL_BODY_INCLUDE, EVAL_PAGE, SKIP_BODY, SKIP_PAGE
 
Constructor Summary
FormatNumber()
           
 
Method Summary
 int doStartTag()
          Create the internal Formatter instance and perform the formatting.
 String getTagName()
          Return the name of the Tag.
 String getType()
          Gets the type of number format to be used.
protected  void localRelease()
          Release any acquired resources.
 void setType(String type)
          Sets the type of number format to be used (number, currency, or percent).
 
Methods inherited from class com.bea.wlw.netui.tags.html.FormatTag
getCountry, getLanguage, getLocale, getPattern, setCountry, setLanguage, setPattern
 
Methods inherited from class com.bea.wlw.netui.tags.AbstractBaseTag
addTagIdMapping, containsExpression, evaluateAttributeToString, evaluateExpression, filter, filter, formatErrorString, formatString, getAttribute, getErrorsReport, getExpressionEvaluator, getJavaScriptUtils, getNearestForm, getNextId, getQualifiedBundleName, getScriptReporter, getUserLocale, hasErrors, isExpression, prepForRendering, registerAttribute, registerError, registerTagError, release, removeAttribute, renderAttribute, renderAttributes, reportErrors, rewriteName, setPageContext, updateExpression, write
 
Methods inherited from class javax.servlet.jsp.tagext.BodyTagSupport
doAfterBody, doEndTag, doInitBody, getBodyContent, getPreviousOut, setBodyContent
 
Methods inherited from class javax.servlet.jsp.tagext.TagSupport
findAncestorWithClass, getId, getParent, getValue, getValues, removeValue, setId, setParent, setValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.servlet.jsp.tagext.Tag
getParent, setParent
 

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 class AbstractBaseTag

getType

public String getType()
Gets the type of number format to be used.

Returns:
the type.

setType

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

Parameters:
type - - the number format type.
Beadoc.attributedescription:
The type of the format to apply. Possible values are number, currency, or percent.
Beadoc.attributesyntaxvalue:
string_type
Beadoc.databindable:
false

doStartTag

public int doStartTag()
               throws javax.servlet.jsp.JspException
Create the internal Formatter instance and perform the formatting.

Specified by:
doStartTag in interface javax.servlet.jsp.tagext.Tag
Overrides:
doStartTag in class FormatTag
Throws:
javax.servlet.jsp.JspException - if a JSP exception has occurred

localRelease

protected void localRelease()
Release any acquired resources.

Overrides:
localRelease in class FormatTag

BEA NetUI tags and APIs are included for backward compatibility only. For new applications, use the Beehive tags and APIs.