Uploaded image for project: 'Apache Flex'
  1. Apache Flex
  2. FLEX-25552

Update Currencyformatter formattingWithCurrencySymbolIsSafe API behavior to always compare requestedISOCode against currency locale's default ISO code

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • Adobe Flex SDK Previous
    • None
    • Spark: Formatters
    • None
    • Affected OS(s): All OS Platforms
      Affected OS(s): All OS Platforms
      Language Found: English

    Description

      We have an api called formattingWithCurrencySymbolIsSafe that is intended to be used to check whether or not the currency type matches the currency of the locale and it is "safe" to use the currency symbol. (Many countries use the same currency symbol (e.g. Canada, USA, and Mexico all use $). For the flash.globalization APIs the use of this would be as follows:

      private function localeChangedHandler() : void { var cf:CurrencyFormatter = new CurrencyFormatter(); var amount:Number = 123.45 // Amount in US Dollars.
      if (cf.formattingWithCurrencySymbolIsSafe(USD))
      trace( cf.format(amount, true ); //$123.45 else

      { cf.setcurrency("USD", "US$"); trace( cf.format(amount, true ); //US$123.45 }

      } With the spark formatters there are a few difference that led to problems of using the above style code in routine that handles a locale change. Here are the differences:

      1. We do not require creating a new spark CurrencyFormatter instance when the locale changes.
      2. If the currencyISOCode or useCurrencySymbol properties are set to other then default values, these overrides are carried forward when the locale changes.
      3. To use a different ISO code in formatting, you must set it on the formatter.

      Our "fix" is to change the behavior of formattingWithCurrencySymbolIsSafe
      to compare against the default value for the currencyISOcode rather than the one currently set.

      With this fix we can create an mxml declaration as follows:

      <s:CurrencyFormatter
      id="cf"
      currencyISOCode="USD"
      currencySymbol="

      { formattingWithCurrencySymbolIsSafe("USD") ? $ : US$}

      "
      fractionalDigits="2"
      useCurrencySymbol="true"/>

      <s:Label text="

      {cf.format(amount)}

      "

      If the locale is changed, then due to binding the currency symbol will change between $ for USA based locales and US$ for non-USA based locales.

      Attachments

        Activity

          People

            adobejira Adobe JIRA
            adobejira Adobe JIRA
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: