webtier@glassfish.java.net

Re: JSF 2.0: locale change only after page refresh

From: <webtier_at_javadesktop.org>
Date: Wed, 03 Feb 2010 07:14:25 PST

Replying to myself (and marking my question as answered):

In Mojarra 1.2_14 and Facelets I get the same erroneous behaviour when I add the following context parameter to web.xml:

  [pre]
  <context-param>
    <param-name>facelets.BUILD_BEFORE_RESTORE</param-name>
    <param-value>true</param-value>
  </context-param>[/pre]

(The parameter does not seem to affect Mojarra 2.0.2 and the behaviour cannot be remedied with it.)

I was able to bypass the problem in 2.0 by "forcing" a new view root build by changing the view root programmatically, e.g. (pay attention to the last 2 rows):

[pre]
   if ("fi_FI".equals(newLanguage)) {
      facesCtx.getViewRoot().setLocale(new Locale("fi", "FI"));
   } else {
      facesCtx.getViewRoot().setLocale(new Locale("en", "GB"));
   }
   [b]UIViewRoot view = facesCtx.getApplication().getViewHandler().
         createView(facesCtx, "/pages/chooseproduct.xhtml");
   facesCtx.setViewRoot(view);[/b][/pre]
[Message sent by forum member 'napu' (panu.korpela_at_sovelto.fi)]

http://forums.java.net/jive/thread.jspa?messageID=384521