JSF Internationalizing

Good day!

It's seems where is a problem with internationalizing JSF application.

Existing implementation of JSF 1.2 doesn't give a chance to use

resources in XML format. Java SE 6 allows developers to use custom

ResourceBundles. Does anybody know how to use custom ResourceBundles in JSF 1.2 framework?

[335 byte] By [JSF_custom_tagsa] at [2007-10-3 8:39:41]
# 1

Hi,

A way to do a custom ResourceBundle.

Create your java class extends from ResourceBundle in a specifc package : com.foo.CustomResourceBundle

And in jsf page use : <f:loadBundle basename="com.foo.CustomResourceBundle" var="lang" />

<h:outputText value="#{lang['data.to.translate']}"/>

In the CustomResourceBundle, you have implement the method public Enumeration getKeys()

In this method you can do what you want, read DB or Xml file ...

Regards.

JP

jean-philippea at 2007-7-15 3:47:49 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

Hi!

here is brief steps to implement resource bundle:

1. create property resource files. for example:

com.custom.Resource.properties

com.custom.Resource_en.properties

com.custom.Resource_de.properties

then fill out them with some values:

key = value

2. In faces-config.xml declare:

<application>

<locale-config>

<default-locale>de</default-locale>

<supported-locale>en</supported-locale>

<supported-locale>de</supported-locale>

</locale-config>

</application>

3. In ur jsf file:

<f:loadBundle basename="com.custom.Resource" var="bundle" />

<h:outputText value="#{bundle.key_name}"/>

looks like it works...

tussena at 2007-7-15 3:47:49 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3

Following this way, I have to create custom ResourceBundle for every resource file. It works good, but it's not a decision of the problem. I want to create class XMLResourceBundle, like PropertyResourceBundle, what will help me to use resources stored in XML format.

Creating custom class for every resource is not a decision.

Thanks.

JSF_custom_tagsa at 2007-7-15 3:47:49 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4
It seems nobody knows how to to this feature. What are you thinking about ading this feature in new release of JSF?
JSF_custom_tagsa at 2007-7-15 3:47:49 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5
http://www.jguru.com/faq/view.jsp?EID=1251281=>"Until JDK 6.0, you can't. Only ListResourceBundles and PropertyResourceBundles are supported. With 6.0, you can create a custom ResourceBundle.Control implementation which allows you to support ANY format, not just XML. "
jean-philippea at 2007-7-15 3:47:49 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 6

I know about JDK 6.0 (see question). The question is: "How to use this feature in JSF1.2"? To tell the truth it's possible to use custom ResourceBundle in desktop applications and other applications that doesn't use frameworks. I used this feature with Struts, it's very simple where.

When JDK6.0 will appear, JSF 1.2 will cannot use many of it's features. I think, it's neaded another implementation of JSF 1.2.

JSF_custom_tagsa at 2007-7-15 3:47:49 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 7

jean-philippe, can you give a link to Java 6 API documentation, where we can read more about the approach, that allows to support any format for ResourceBundles? Now I see, that if JSF instantiates java.util.PropertyResourceBundle, it cannot load, for example, XML properties (which should be enough for most cases).

dma_ka at 2007-7-15 3:47:49 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 8
Hi,is there a solution for JSF and the Resourcebundle.Control class without a workaround ?I don't know where i can change the built-in behavior of the JSF Resourcebundle.Any suggestions ?Thanx in advance,Udo
Udo.Krassa at 2007-7-15 3:47:49 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...