13 Replies Latest reply on Dec 29, 2009 7:56 AM by fcorneli

    Seam Locale issues

    bashan

      Hi,


      I am trying to work with Seam and Locales, but having several issues.
      These are my configurations:
      faces.config.xml:


        <application>
          <locale-config>
            <default-locale>iw</default-locale>
            <supported-locale>iw</supported-locale>
            <supported-locale>en</supported-locale>
          </locale-config>
          <message-bundle>com.bundle.messages</message-bundle>
          <view-handler>com.sun.facelets.FaceletViewHandler</view-handler>
        </application>



      components.xml:


        <international:locale-config default-locale="iw">
          <international:supported-locales>
            <value>en</value>
            <value>iw</value>
          </international:supported-locales>
        </international:locale-config>
      
        <core:resource-loader>
          <core:bundle-names>
            <value>com.bundle.messages</value>
          </core:bundle-names>
        </core:resource-loader>
      
        <core:locale-selector cookie-enabled="true" locale="iw"/>



      My issues:
      1) When application loads, the default Locale is English and not Hebrew (iw). Switching between the Locales (by changing LocaleSelector.instance().setLocale() is working fine).
      2) When I am sending mail using Seam mail, the mail is being sent in Hebrew (iw). Switching between Locales has no effect. It is always being sent in Hebrew (iw).
      3) Switching between Locales is not stored in the browser cookie. When I switch to Hebrew Locale, then reload the web application, it loads up with English again.


      Any ideas?



        • 1. Re: Seam Locale issues
          titou09

          Could your problem related to JIRA-4401 ?

          • 2. Re: Seam Locale issues
            bashan

            I tried putting ConfigureListener first in web.xml with no much luck. The problems are still the same.

            • 3. Re: Seam Locale issues
              bashan

              Any ideas? Maybe there is a problem in my configuration?

              • 4. Re: Seam Locale issues
                tony.herstell1

                As for remembering your choice of locale...


                Have you added this to components.xml?


                     
                <!-- Remember the locale selected -->
                <international:locale-selector cookie-enabled="true"/>
                



                • 5. Re: Seam Locale issues
                  bashan

                  I added this line:


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



                  Does it matter?



                  • 6. Re: Seam Locale issues
                    tony.herstell1

                    I always check the manual that goes with the version of seam I am using.


                    That may be right for your version.


                    Now when you re-visit your site it should remember your choice of language.


                    Works for me.


                    • 7. Re: Seam Locale issues
                      bashan

                      I am running the latest version of Seam.
                      Is there any example project you can point me to?

                      • 8. Re: Seam Locale issues
                        bashan

                        well?? Can any anyone please help?


                        I am trying to make Seam International work with no luck.
                        When I change locale using: LocaleSelector.instance().setLocale(Locale.US)
                        and then restart the application, the language is not saved to cookie.
                        And another problem: When sending mail (with Seam mail), the language of the mail is not the same language of the LocaleSelector.


                        Can anyone please supply an example configuration that works? I am using Seam 2.0.2 GA

                        • 9. Re: Seam Locale issues
                          bashan

                          OK,I managed fixing the cookie thing.
                          It seems like the method: select() of LocaleSelector causes the Locale setting to be stored in the cookie. So when changing locale I do:
                              LocaleSelector.instance().setLocale(Locale.US);
                              LocaleSelector.instance().select();


                          But I still have one problem, which looks like a bug in Seam:
                          When sending mail using Seam (using: Renderer.instance().render()), it looks like Seam uses the default Locale to send the mail, rather then the current selected Locale. This happens only if Locale was not stored in cookie yet.


                          Does it looks like a bug?

                          • 10. Re: Seam Locale issues
                            xsalefter.xsalefter.yahoo.com

                            Hi.. I stuck in the same problem too. Can anyone resolve this problem? I think this is a bug, because if you try to add a default locale provided by seam like fr(Franch) or de(Deutsch), It is work well.


                            Thanks.

                            • 11. Re: Seam Locale issues
                              fcorneli

                              I'm having the same problem because the select() method is not invoked when doing something like:


                              <h:selectOneMenu value="#{localeSelector.localeString}" onchange="submit();">
                                <f:selectItems value="#{localeSelector.supportedLocales}" />
                              </h:selectOneMenu>



                              The auto-submit via the onchange works for the current session, but doesn't make the language persistent via the cookie. How do I invoke the select() method on the localeSelector via the onchange? I really would like to keep the onchange behaviour as it makes the language selection more natural for the user.

                              • 12. Re: Seam Locale issues
                                fcorneli

                                The following does the trick of immediately changing the locale and at the same time persisting the locale selection via a cookie:




                                <h:selectOneMenu value="#{localeSelector.localeString}" onchange="submit();">
                                    <f:selectItems value="#{localeSelector.supportedLocales}" />
                                    <a4j:support event="onchange" action="#{localeSelector.select}" ajaxSingle="true"/>
                                </h:selectOneMenu>



                                • 13. Re: Seam Locale issues
                                  fcorneli

                                  This works as long as you're running your (SSL secured) web application on a local JBoss AS. When deploying to a remote JBoss AS it stops working. Seems like the org.jboss.seam.core.Locale cookie has the Path simply set to / and no Secure enabled, which makes Firefox to fail persisting the cookie. The org.jboss.seam.core.Locale cookie should inherent some flags from the JSESSIONID cookie I guess.