3 Replies Latest reply on Oct 25, 2011 9:27 AM by ratking

    Seam-International Glassfish 3.1 - AvailableLocales

    bardioc

      Hello,


      I've been trying to utilize seam-international (3.1.0-beta3) in an application deployed at the current Glassfish 3.1. I've followed the documentation and implemented a class to retrieve the current users locale as well as being able to change it via the event.


      However, for me it seems impossible to implement a way to retrieve all available locales. I've implemented a class as found in the documentation:



      import javax.annotation.PostConstruct;
      
      import org.jboss.seam.international.locale.LocaleConfiguration;
      
      public class CustomLocaleConfiguration extends LocaleConfiguration 
      {
          @PostConstruct
          public void setup() 
          {
              addSupportedLocaleKey("en");
              addSupportedLocaleKey("de");
          }
      }



      In an application scoped bean, I try to inject all available locales as follows:





      @Named
      @SessionScoped
      public class LocaleManager implements Serializable
      {
          ...
          @Inject
          private List<Locale> locales;
      
          public List<Locale> getLocales()
          {
              return locales;
          }
      }



      However, this injected attribute is always an empty list. My custom implementation (CustomLocaleConfiguration) is never called. I've tracked down, that method init() of the class org.jboss.seam.international.locale.AvailableLocales is called, but somehow configuration.isUnsatisfied() is always 'true', so no configuration is retrieved.


      What am I missing here to configure. The documentation is very limited on the module, despite containing a valuable example that actually works.


      Besides this configuration, no other configuration is done right now. I've refused to add any XML-based configuration, cause I do not want XML anymore, thats the reason behind switching to CDI, isn't it?


      Thank you for your help,


      Best regards,


      Heiko

        • 1. Re: Seam-International Glassfish 3.1 - AvailableLocales
          lightguard

          I'd have to look at try (this could certainly be done with an arquillian test to verify it across servers). I've also ask Ken to take a look. Would you mind trying JBoss AS7? Glassfish still has some bugs in their CDI integration.

          • 2. Re: Seam-International Glassfish 3.1 - AvailableLocales
            kenfinni

            Heiko,


            I'm not sure what's happening there, as your code appears identical to the tests we run in the international testsuite as part of the build.


            If you look at CustomLocaleConfiguration and AvailableLocalesTest, they are identical to yours.


            Are there any Weld warnings on startup?


            Otherwise, I'd have to agree with Jason that this looks like a bug in CDI integration of Glassfish as these tests run fine on AS7 and Weld Embedded.


            Ken

            • 3. Re: Seam-International Glassfish 3.1 - AvailableLocales
              ratking

              // try this ...
              import javax.annotation.PostConstruct;
              import javax.enterprise.event.Observes;
              
              import org.jboss.solder.servlet.WebApplication;
              import org.jboss.solder.servlet.event.Initialized;
              import org.jboss.seam.international.locale.LocaleConfiguration;
              
              /**
               * Init data when Solder Servlet fires an event notifying observers that the web application is being initialized.
               */
              public class CustomLocaleConfiguration extends LocaleConfiguration 
              {
                  public void setup(@Observes @Initialized WebApplication webapp) 
                  {
                      addSupportedLocaleKey("en");
                      addSupportedLocaleKey("de");
                  }
              }