Renders a value in the currency pattern of the recognized locale.

Attributes

Description

currency

Automatic/Required

Set to true or false.

Usage Notes

The currency converter renders a value in the currency pattern of the recognized locale. In the following example, no locale is explicitly specified:

<dsp:valueof bean="PriceInfo.amount" converter="currency"/>

If no locale is specified, the locale is determined as follows, in descending order of precedence:

A specified locale always has precedence, as in the following example:

<dsp:valueof bean="PriceInfo.amount" locale="en_US" converter="currency"/>

Each locale provides a default setting that determines:

Tag Converter Extensions: euro and currencyConversion

ATG provides two converters, currencyConversion and euro, which let a site display prices in multiple currencies. The classes of these converters extend the currency tag converter class atg.droplet.CurrencyConverter:

These tag converters can take the following attributes:

Attributes

Description

symbol

Valid for euro and currencyConversion converter.

This attribute substitutes the specified HTML entity—typically, &euro;—for the euro currency symbol. This attribute is generally useful for applications that use Latin-1 (ISO 8859-1) encoding, which does not support the euro currency symbol.

reverse

Valid for currencyConversion, this attribute reverses the conversion, so it converts from the currency of the user’s locale to the currency of the specified locale.

The following example uses the euro converter to display a price in Euros. The locale attribute specifies how to format the output.

<p>Price in Euros: <dsp:valueof locale="en_UK"
   bean="PriceInfo.amountInEuros" converter="euro" symbol="&euro"/>

In the next example, the dsp:valueof tag uses the currencyConversion converter to display the price in British pounds. The exchange rate is obtained from the resource file atg/droplet/ExchangeRates.properties:

<p>Price in British Pounds: <dsp:valueof locale="en_UK"
   bean="PriceInfo.amountInEuros" converter="currencyConversion"/>

If locale indicates a non-euro country such as the United States, the currency converter returns null and the dsp:valueof tag returns its default value, if any is provided.

The euro and currencyConversion converters use the same algorithm as currency to discover a locale. In the following example, no locale is specified. If the locale is a country that uses the euro, the value of priceInfo.amountInEuros is converted to the appropriate currency (using the official exchange rates) and displayed in the appropriate format for that locale. If the locale is not a country that uses the euro, the price is displayed as $5.00.

<dsp:valueof bean="priceInfo.amountInEuros" converter="currencyConversion">
  Current locale does not use Euros
</dsp:valueof>

The currencyConversion provides a reverse attribute that converts from a locale-specific European currency (for example, British pounds) into Euros:

<dsp:valueof locale="en_UK_EURO" bean="priceInfo.amountInEuros"
  converter="currencyConversion" reverse="true" symbol="&euro;">
  no price
</dsp:valueof>

In this example:


Copyright © 1997, 2013 Oracle and/or its affiliates. All rights reserved. Legal Notices