2 Replies Latest reply on Nov 7, 2006 11:18 AM by antispart

    How to change locale from a Session Bean?

    antispart

      Instead of using the SelectItems method as described in the examples I'd like to have images that represent each country (flags) that when clicked will change the locale.

      This changes the locale but not the message bundle that is used. So, dates and times are formated properly but the message.properties is still used instead of messages_fr.properties when the locale is switched to French.

      Any ideas what I'm doing wrong?

      header.xhtml:

      <h:form id="localeForm">
      <s:link action="#{visitManager.changeLocale('en')}">
      <h:graphicImage url="/img/en.gif" />
      </s:link>
      &#160;
      <s:link action="#{visitManager.changeLocale('fr')}">
      <h:graphicImage url="/img/fr.gif" />
      </s:link>
      </h:form>


      visitManagementBean.java:

      public String changeLocale(String locale) {
      FacesContext.getCurrentInstance().getViewRoot().setLocale(new Locale(locale));
      return null;
      }