OK thx Gianni.
So if I sum up things :

2 solutions to dynamically change your application locale :

*1- If you use the server STATE_SAVING_METHOD with somes </redirect> 
instructions :
Create a bean to save the locale choice
This bean must be in session scope or request + saveState
Then in each page of your application that needs to be localized, add the 
locale parameter to them : <f:view locale="#{localeBean.locale}">

*2- If you use the client STATE_SAVING_METHOD ( -> no </redirect> instructions) 
:
Use the UIViewRoot.setLocale(Locale l) method.
For example : 
FacesContext.getCurrentInstance().getFacesContext().getViewRoot.().setLocale(l);

Regards,
Clément

-----Message d'origine-----
De : [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Envoyé : vendredi 26 août 2005 15:48
À : MyFaces Discussion
Objet : Re: TR : Dynamic Locale change


I suggest you take a look at the list archives for "Maintain locale  
across views".
I had a similar issue and it seems the locale is not maintained  
across views when a <redirect/> is used.
In the end I set <f:view locale="#{visit.locale}">, where visit is a  
session scoped bean.
Gianni



>
>> 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