webtier@glassfish.java.net

Re: Changing Locale Dynamically

From: <webtier_at_javadesktop.org>
Date: Sun, 30 May 2010 11:58:50 PDT

Hi,
If we use swapLocale() like this, it works

public void swapLocale(ActionEvent e) {

        if (locale == Locale.ENGLISH) {
            locale = new Locale("es");
            FacesContext.getCurrentInstance().getViewRoot().setLocale(locale);
        } else {
            locale = Locale.ENGLISH;
            FacesContext.getCurrentInstance().getViewRoot().setLocale(locale);
        }
    }

(Now, we don't even need the locale attribute on f:view)

even i am curious about the lifecycle issue in your code. Hopefully somebody will put some light on it.
=====
Plus one more thing, jsf 2: complete reference says f:loadBundle is not recommended, use
<resource-bundle>
            <base-name>com.all.Messages</base-name>
            <var>msgs</var>
</resource-bundle>

reason given is( from the complete reference book): Previous versions of JSF recommended using the f:loadBundle tag. Since JSF 1.2, this is no longer recommended because it fails in the case of Ajax and partial page updates because the f:loadBundle tag may not always be executed in those cases.
[Message sent by forum member 'nash_era']

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