If you set the locale in the UIViewRoot manually, I don't know if it will be passed on to the next UIViewRoot.

One solution for you might be putting the users locale in the session (e.g. the key "locale" or "user.locale" if your have a user object) and use the locale attribute <f:view locale="#{locale}"> or <f:view locale="#{user.locale}"> on all of your JSF pages.

regards,

Udo

Clément Maignien wrote:

Sorry for asking so much questions but I'll have to present my webapp very soon and I need the multi-language to works fine. Has anybody any idea ? Why the locale is reset to the default one ? Could it comes from a <redirect/> instruction in my faces-config.xml ? Ty for your help :D
Clément
-----Message d'origine-----
*De :* Clément Maignien
*Envoyé :* lundi 22 août 2005 18:18
*À :* MyFaces Discussion
*Objet :* Dynamic Locale change

Hi,
I'm trying to allow the application user to change the language of my web app. I did it the way it is done in the myFaces 1.0.9 examples : a selectOneMenu with a choice of languages and an action button with that code : OptionBean {
...
public String action {
    ...
    FacesUtil.setLocale(selectedLocale);
    ...
}
...
}
FacesUtil {
...
public static void setLocale(Locale l) {
    
FacesContext.getCurrentInstance().getFacesContext().getViewRoot().setLocale(l);
}
...
}
It works fine when the action is executed (the language change), but as soon as I navigate to another page of the App, the language is resetted to the default one. Why ? NB : I'm trying not to use the /locale/ parameter of the /f:view/ tag ... Thx,
Clément.

Reply via email to