Please disable your adblock and script blockers to view this page

Search this blog

Showing posts with label Locale. Show all posts
Showing posts with label Locale. Show all posts

Sunday 5 February 2017

Change live application language/resource in Oracle ADF, Change XML Resource file at runtime


Hello All

I have posted about using external XML file as List resource bundle earlier , the aim of resource file is to read application static text from some source so that we can change that without compiling and redeploying application

Next requirement is to change application language , sometimes we need support multiple langauge in ADF application and it requires change in all static text so for this I am going to use separate XML resource file for different language and in this post I'll show that how to update resource file in a live running application

Friday 5 July 2013

Changing af:convertNumber Format according to Locale- Oracle ADF

Simple post with very simple application-
we can covert a Numeric field format according to standard locale in ADF Faces.
when we have a numeric field on page there is a converter inside it, called af:convertNumber is extension of the standard JSF javax.faces.convert.NumberConverter.

 user can change it for Integer digits , fraction digits etc. but here i am talking about format of Number(Amount), to do this follow these steps.
  • Change GroupingUsed to true, by default it is true
  • Now set Locale, you can do this using managed bean or simply write it here
  • Managed Bean code to create Locale-  private Locale format=Locale.ENGLISH;
  • Now see various formats of Amount using Locale-



Using en-US-
 Using fr-
 Using hi-IN-for Hindi fonts
 Using de-DE -




so this is the thing how you can change formatting , this can also be done by managed bean.

  • Create a variable of type Locale and its getter -setter
  • Use it in Locale field of af:convertNumber  

  •     public void chinaButton(ActionEvent actionEvent) {
            this.setFormat(Locale.CHINA);
        }
        public void frenchButton(ActionEvent actionEvent) {
            this.setFormat(Locale.FRENCH);
        }
    
        public void italianButton(ActionEvent actionEvent) {
            this.setFormat(Locale.ITALIAN);
        }
    

  • You can also set Max and Min fraction digits in af:convertNumber

Thursday 4 April 2013

Currency- A Java Utility, Get currency code , symbol using Locale in Java

Java provides utility classes inside java.util package.
java.util.Currency is very interesting class in this package,it represents currencies defined in ISO 4217 by 
their currency codes.
You can get currency codes, its symbol, default fraction digits using its method.




java.lang.Object
  extended by java.util.Currency 


see this short example , how we use Currency Class in Java,You can also get 
live currency fluctuation in java using Currency Converter API
 
package practiceJava;

import java.util.Currency;
import java.util.Locale;

public class CurrencyDemo {

    public static void main(String[] args) {
        // create a currency object with  locale
        Locale locale = Locale.US;
        Currency curr = Currency.getInstance(locale);
        System.out.println("Locale's currency code:" + curr.getCurrencyCode());
        // Get symbol for Currecny
        String symbol = curr.getSymbol();
        System.out.println("Symbol is :" + symbol);
        // Get default fraction digit for Currecny
        int frDigit = curr.getDefaultFractionDigits();
        System.out.println("Default fraction digit : " + frDigit);

    }
}


Output look like this