Friday, June 26, 2009

Oracle ADF and International Characters

My team is developing application in Oracle ADF with internationalization support. When we did preliminary tests, we have noticed that we can't save local characters to database, entered characters simply were transformed to code representation. Our database character set is not UTF-8, but local. We were lucky to find very elegant solution - just to change content type charset of our pages. We have changed it to UTF-8, inside our JSPX pages, and ADF automatically transforms it to database character set. This means, same approach works when we have UTF-8 charset in database, or any local charset as well.

You can download my sample application -, where you can test how it works on your database.

Let's say we have simple form:

And type text in local language for First Name field, this time in Russian. When user will want to store this record and will invoke Commit, local language characters will be transformed to unreadable form by default:

I saw people are asking related questions quite frequently on OTN forums. Actually solution is simple, we just need to change page content type charset from default one:

To UTF-8 charset:

This will allow to accept local characters on JSPX page and to transfer them through ADF Business Components to database. And now Russian text is saved to database without problems:

And if to check database, here is this text stored:

Finally, its important to mention, that if your database is installed with UTF-8 support, you can store all local characters. But, if you have database with specific character set, you can store only this specific charset from JSPX pages. Its good thing you dont need to modify your JSPX pages in both cases, just declare UTF-8 for page charset encoding. My database is installed with UTF-8 charset:


Martin said...


very nice explanation. Is it possible to join the contentType-Attribute with a Managed Bean (I get a error in my test) or to build two PageTemplates (one for windows-1252 and the other for utf-8)?

I Build a ADF-Template with contentType="text/html;charset=utf-8" and deploy it as a ADF Library Jar and add it to another project. But in the JSF-pages (which uses the template)the contentType is set to contentType="text/html;charset=windows-1252".

Have you any idea?

kind regards

Paulo said...

Hi Martin

If you go to Jdeveloper's menu "Tools -> Preferences" you can alter the default encoding of all your new pages to UTF-8.

As to the pages already created the better choice is to modify them to use UTF-8.

Anonymous said...

Hi Paulo,

could you be more explicit where in the menu "Tools -> Preferences" you change the default encoding ?



Andrejus Baranovskis said...


Its in Environment section (opens by default), Encoding combobox.


Anonymous said...

I am using UTF-8 charset in jspx.
There is a value القاموس in arabic in db and I am displaying that in jspx.Its getting displayed القاموس even if the browser locale is en english. If I need to display english equivalent of this value if browser locale is en, how can I do this ?

Please help .. Is this possible?


Andrejus Baranovskis said...


It should display english value, if it will be in DB.


Amar said...

In my JSPX page I had form which display the data based on Query based View object. Now the data to be translated based on language selection.

Is it possible to have a property file for Query based view object depend upon language or let me know for alternative approach.

Andrejus Baranovskis said...

Not sure, may be this post will help:


Gabriel Albuquerque said...

Hi Andrejus,

I'm using JDeveloper version and I'm using the "Reformat" option with the "Save Actions" in the "Preferences" and the enconding is set to UTF-8 and using the tag "". I'm trying to save the code and it is getting modified to characters like "ç" (for "ç") and "ã" (for "~"). Is there a workaround for this issue?

Thank you,

Gabriel Albuquerque said...

Hi Andrejus, Gabriel again

Here an example what I get:

The "text" should be "Ações", but it was set to wrong characters when I tried to save the code.

Thank you,