11 Replies Latest reply on Jun 12, 2007 2:47 PM by Eleas

    LocaleSelector

    Johann Meier Newbie

      The suggested way to allow the user to set the locale manually has no effect in my application.
      I use the following code from chapter 13.1 of the reference documentation:

      <h:selectOneMenu value="#{localeSelector.localeString}">
      <f:selectItems value="#{localeSelector.supportedLocales}"/>
      </h:selectOneMenu>
      <h:commandButton action="#{localeSelector.select}" value="#{messages['ChangeLanguage']}"/>


      After clicking the command button nothing happens. Any suggestions?

      Thank you in advance!

        • 1. Re: LocaleSelector
          Carsten Hoehne Master

          I suppose that you have configured your supported locales in faces-config.xml?

          • 2. Re: LocaleSelector
            Seto Kaiba Expert

            What do mean with "nothing happens"?

            • 3. Re: LocaleSelector
              Johann Meier Newbie

               

              I suppose that you have configured your supported locales in faces-config.xml?

              Yes I have it configured in faces-config.xml
              <locale-config>
               <default-locale>en</default-locale>
               <supported-locale>en</supported-locale>
               <supported-locale>de</supported-locale>
              </locale-config>
              


              What do mean with "nothing happens"?

              If I try to switch between my configured locales with the commandButton the localized messages of the choosen language aren't shown. Even if I hit the reload button of the browser. The properties files are OK because if I change the language in the browser it is shown the right way.


              • 4. Re: LocaleSelector
                Carsten Hoehne Master

                In the dark ages of my seam experience i had often forgotten to place command buttons into forms.:-(
                That is the only explanation that i have.
                Your ui code is fully functional but only if surrounded wit form tags.
                Ciao,
                Carsten

                • 5. Re: LocaleSelector
                  Johann Meier Newbie

                  Thank you for the hint. Unfortunately I have the code surrounded with form tags :(

                  • 6. Re: LocaleSelector
                    Carsten Hoehne Master

                    Hello,
                    if you found the reason why, please inform me.
                    I do have a similar problem with a command button. The action of the button is not triggered and i can not figure out why. Other buttons on the page work but this one don't.

                    Ciao,
                    Carsten

                    • 7. Re: LocaleSelector
                      Carsten Hoehne Master

                      Good and bad news from me.

                      Localisation works for me only with normal resource bundles.
                      Now i have detected that it do not work with the seam resource bundle named messages.

                      I do have a form like this (bundle is the bundle loaded with f:loadbundle):

                      <s:validateAll>
                       <h:panelGrid border="1" cellspacing="2" id="User" columns="3">
                       <h:outputLabel value="#{bundle.userlogin}" for="login" />
                       <h:inputText id="login" value="#{myUser.login}" required="true">
                       <f:validateLength minimum="5" maximum="30" />
                       </h:inputText>
                       <h:message for="login" styleClass="errors" />
                      
                       <h:outputLabel value="#{bundle.userpassword}" for="password" />
                       <h:inputText id="password" value="#{myUser.password}" />
                       <h:message for="password" styleClass="errors" />
                       </h:panelGrid>
                      </s:validateAll>
                      

                      Now this happens:
                      The error message for the login field is taken from my bundle and displayed in the language selected with the localeselector.

                      The error message for password is taken from the seam messages bundle and displayed in the browsers default language. (regardless of the selection with the localeselector:-)
                      What is going wrong here?
                      Ciao,
                      Carsten

                      • 8. Re: LocaleSelector
                        Carsten Hoehne Master

                        One more interesting thing:
                        If i add 'messages' to the message Bundles in faces-config.xml
                        I am no more able to verwrite the myfaces messages.

                        What shuld we do to receive the correct language withe Seams messages?

                        • 9. Re: LocaleSelector
                          Johann Meier Newbie

                          For my application I was able to narrow the problem a little further. It looks like it has somthing to do with ICEFaces I used.

                          I tried some tests with the new seam 1.2 version. After setting up a new project with seam-gen the locale selector function does very well. Even if I used it with the cookie-enabled selector in the components.xml

                          <core:locale-selector cookie-enabled="true"/>


                          After configuring ICEFaces like it is in the example application the following error occured:

                          ERROR [com.icesoft.faces.facelets.D2DFaceletViewHandler] Problem in renderResponse: /layout/template.xhtml @19,72 value="#{localeSelector.supportedLocales}": Cannot get value for expression '#{org.jboss.seam.core.localeSelector}'
                          javax.faces.el.EvaluationException: /layout/template.xhtml @19,72 value="#{localeSelector.supportedLocales}": Cannot get value for expression '#{org.jboss.seam.core.localeSelector}'
                           at com.sun.facelets.el.LegacyValueBinding.getValue(LegacyValueBinding.java:60)
                           at javax.faces.component.UISelectItems.getValue(UISelectItems.java:55)
                           at com.icesoft.faces.renderkit.dom_html_basic.MenuRenderer.getSelectItems(MenuRenderer.java:576)
                          ...


                          If I don't use the cookie-enabled selector the application seems to work well but the localeSelector functionality has no effect after clicking the button.

                          It seems there are incompatibilities between ICEFaces and the localeSelector.



                          • 10. Re: LocaleSelector
                            Carsten Hoehne Master

                            My problem is solved.
                            I had created a messages.properties and a messages_de.properties.
                            Where i assume that messages.properties is used whenever a key in the german version is not found and when a language is selected which does not exist.
                            But in my case, the german version messages_de.properties was the fallback file:-(

                            As i created messages_en.properties, the language selection works.

                            • 11. Re: LocaleSelector
                              Eleas Newbie

                              Good day!

                              I have the same problem in 1.2.1GA. And, as I see, there is no explanations how to fix in this topic. Does anybody know the solution?