1

i am using htmlpanelgrid with to build my dynamic navigation. The Page contains 3 commandlinks for changing the language (with an image). If i hit the image (commandlink) to change the language, the navigation is always 1 step behind with the new language.

The navigation become build on Phase 1 (restore view) and the new language is set on Phase 5. Means, if i change the language the htmlpanelgrid is build with the old language before the new value is set. how to get rid of that ? thanks!

Sence
  • 115
  • 8

1 Answers1

0

You need to set the locale explicitly on the UIViewRoot during the action method.

public void changeLocaleAction() {
    locale = new Locale(language);
    FacesContext.getCurrentInstance().getViewRoot().setLocale(locale);
}

Otherwise you need to send a redirect back to the same view.

public String changeLocaleAction() {
    locale = new Locale(language);
    return FacesContext.getCurrentInstance().getViewRoot().getViewId() + "?faces-redirect=true";
}

See also:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • the locale is stored in a session Bean, and the trick with: return FacesContext.getCurrentInstance().getViewRoot().getViewId() + "?faces-redirect=true"; did it, thanks again! and have a nice day – Sence Feb 29 '12 at 19:28