tags:

views:

72

answers:

1

(WARNING: this is my first java application, coming from .NET, so don't bash me if I write too much garbage)

I'm developing a simple JSF 1.2 web application which should support Russian, Chinese, and other languages outside ISO 8859-1, which is automatically used in Properties.load().

Is there a way to use the Properties loaded from XML files, with Properties.loadFromXml(), inside JSF, without writing too much code?

I know there are alternative ways to do so (writing my own loader, escaping the characters...), but I'd really love to find a simple solution, and I don't see it in all the forums I checked.

Thanks in advance for any help

+2  A: 

I think the most widely used approach is to encode your .properties files with unicode escape sequences. This can easily be done with the AnyEdit plugin for Eclipse.

The problem is that ResourceBundle uses the Properties(inputStream) constructor, rather than Properties(reader).

You can use your own LoadBundle component instead of f:loadBundle to overcome this, but you'll have to:

  • extend the original one
  • define it as custom component (facelets and/or jsp)
  • define a new ResourceBundle implementation
  • instantiate it, using new InputStreamReader(classloader.getResourceAsStream(..))
Bozho