0 Replies Latest reply on Nov 5, 2007 7:12 PM by parki

    Simple question about how to set up locale stuff

    parki

      Hi!

      The lightbulb is starting to glow a bit brighter, but I'm still stumped on some (likely) easy stuff. Hoping someone can take 5 and help me out.

      I would like to change locales on the fly. My app has internationalization and localization - the issue is being able to change it on the fly in the user interface.

      I have an object exposed as a bean, and it has accessors:

      public List getSupportedLocaleItems() { ... }
      public String getLocale() { ... }
      public void setLocale(String locale) {
      FacesContext.getCurrentInstance().getViewRoot().setLocale(new Locale(locale));
      }

      I want a drop down ("h:selectOneListbox" ?) to display the locales available, and when one is selected, to have the page update immediately with the locale change. So I tried:

      <h:selectOneListbox id="locale_select" size="1" value="#{bean.locale}" immediate="true">
      <f:selectItems value="#{bean.supportedLocaleItems}" />
      </h:selectOneListbox>

      I have two problems:

      1. Using immediate="true" doesn't seem to do what I want, namely to fire the bean.setLocale when the item is selected. It still waits for a form submission of some kind.

      2. When I do submit the form via a button, I get an error:

      18:57:05,631 WARN [lifecycle] executePhase(RENDER_RESPONSE 6,com.sun.faces.context.FacesContextImpl@6bc276) threw exception
      java.lang.IllegalArgumentException: Expected a child component type of UISelectItem/UISelectItems for component type javax.faces.SelectOne(locale_select). Found null.

      which I don't quite understand.

      Any help is appreciated - I think it's a pretty simple problem, but I'm not seeing it.

      Oh, and question #3 - is there a good reference to learn some of this stuff? I bought "JavaServer Faces In Action" by Mann and am finding it extremely difficult to figure things out - he jumps all over the place - I need more of a reference with a "big picture" angle.

      I'm really liking this, just not quite exactly figuring out how it all hangs together (I'm a solid java developer, just not done any web side work, so there's a lot to learn).

      Much appreciated.

      parki...