ClassName

atg.droplet.CurrencyFormatter

Component

/atg/dynamo/droplet/CurrencyFormatter

The CurrencyFormatter servlet bean takes a numeric value and displays that value as a currency amount, formatting it based on the locale. The formatting includes the currency symbol, the placement of the symbol, and the delimiters used. For example, if the value passed in is 20000, and the locale is en_US, the servlet bean formats the value as $20,000.00; if the locale is de_DE, the servlet bean formats the value as 20.000,00 DM.

Input Parameters

currency
The numeric value to format. This value can be expressed as either a java.lang.Number or a String.

locale
This optional parameter holds the locale that is used to determine the formatting of the currency amount. This value can be either a java.util.Locale object or a String that represents a locale (such as en_US). If you do not use this parameter to provide a locale explicitly, the ATG platform uses the default locale supplied in the request object.

euroSymbol
This optional parameter lets you format the currency amount with a euro symbol even if your encoding does not support it; the character set ISO 8859-1 (Latin-1), for example, does not include the euro character. For the value attribute, specify the HTML code for the ASCII euro symbol as shown here:

<dsp:param name="euroSymbol" value="&euro;"/>

You must use the valueishtml attribute with a <dsp:valueof> tag in the formattedCurrency parameter so the ATG platform displays the HTML euro symbol. Without using this attribute, the ATG platform displays the value literally rather than process it as HTML code.

<dsp:oparam name="output">
  <dsp:valueof param="formattedCurrency" valueishtml="true">no
  price</dsp:valueof>
</dsp:oparam>

yenSymbol
This optional parameter lets you format the currency amount with a yen symbol even if your encoding does not support it; the character set ISO 8859-1 (Latin-1), for example, does not include the yen character. For the value attribute, specify the HTML code for the ASCII yen symbol as shown here:

<dsp:param name="yenSymbol" value="&yen;"/>

You must use the valueishtml attribute with a <dsp:valueof> tag in the formattedCurrency parameter so the ATG platform displays the HTML yen symbol. Without using this attribute, the ATG platform displays the value literally rather than process it as HTML code.

<dsp:oparam name="output">
  <dsp:valueof param="formattedCurrency" valueishtml="true">no
  price</dsp:valueof>
</dsp:oparam>

For more information on the valueishtml attribute, see Displaying Values that Contain HTML.

Output Parameter

formattedCurrency
The formatted currency value.

Open Parameter

output
The output to render.

Example

In this example, the CurrencyFormatter renders the value 1059 in the appropriate format. The specified value is saved to the priceToDisplay parameter, which is processed through the CurrencyFormatter. The CurrencyFormatter applies the locale provided by OriginatingRequest component to the priceToDisplay value and saves it to the formattedCurrency parameter, which is displayed in the JSP. If the locale in OriginatingRequest is set to en_US, the rendered value is $1059.00.

<dsp:setvalue param="priceToDisplay" value="1059"/>
<dsp:droplet name="/atg/dynamo/droplet/CurrencyFormatter">
  <dsp:param name="currency" param="priceToDisplay"/>
  <dsp:param name="locale" bean="/OriginatingRequest.requestLocale.locale"/>
  <dsp:oparam name="output">
    <p>Current price:  <dsp:valueof param="formattedCurrency"/>
  </dsp:oparam>
</dsp:droplet>

The second example shows how to use the euroSymbol parameter with the valueishtml attribute of the <dsp:valueof> tag to display an amount with the euro symbol. This code displays a value of 3,99 € €€€€€€€.

<dsp:droplet name="/atg/dynamo/droplet/CurrencyFormatter">
  <dsp:param name="currency" value="3.99"/>
  <dsp:param name="locale" value="de_DE_EURO"/>
  <dsp:param name="euroSymbol" value="&euro;"/>
  <dsp:oparam name="output">
    <dsp:valueof param="formattedCurrency" valueishtml="true">no
    price</dsp:valueof>
  </dsp:oparam>
</dsp:droplet>
 
loading table of contents...