File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSF and the fly likes locales and jsf Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "locales and jsf" Watch "locales and jsf" New topic

locales and jsf

dan volfman

Joined: Jan 15, 2010
Posts: 6
i have a few questions about jsf and localization.
assume i have the following definition in faces-config.xml

In my jsf page i use to get the value of abc (which is mapped in i also have

the question is - what locale is used in in this bundle?

i configured the locales:

but it didnt make the page take the values from labels_de.
only when i define <f:view locale="de_DE"/> in the page, the value is taken from
Can someone please explain how this works?


Ilari Moilanen
Ranch Hand

Joined: Apr 15, 2008
Posts: 199
First of all you don't have to put the view tag to all of your pages. You can put it in a template file and then all your pages that use that template have it defined.

When you define the locale change it to point to a backing bean (or to facescontext) so that it can change dynamically. I for example have it defined like this
so I can change the locale as I want based on the users preferences.

I can explain how it works in more detail if you want (when I have more time).

The reason we need to use the f:view tag at all is not clear to me but maybe somenone here on this forum can explain the technical details >
Jose Berardo

Joined: Oct 28, 2010
Posts: 9
I believe that your browser is sending en_US in its Accept-Language header.
The Accept-Language is the major precedence information about locales. To use another you need the f:view or programatically change the ViewRoot's locale attribute:

I'm having a problem closed to yours. If you solve yours, please take a look at mine:

Brendan Healey
Ranch Hand

Joined: May 12, 2009
Posts: 218

Try it without the country specific detail. You're definitely on the right track, perhaps your
browser settings are incorrect (preferred languages).

I agree. Here's the link:
subject: locales and jsf
It's not a secret anymore!