4 Replies Latest reply on Nov 24, 2006 2:27 PM by gavin.king

    Update to Seam i18n to support resource bundle types related

    christophe.laumond

      Hi all,

      We are using
      jboss-seam-1_1.1.0.CR1
      jboss-4.0.5.GA - ejb3 profile using jems installer

      We need to change the language in our webapplication according to administrator settings and we want to give the possibility to change any test in a database.

      We have found this post in JIRA :

      Update to Seam i18n to support resource bundle types
      http://jira.jboss.com/jira/browse/JBSEAM-421

      which is a change included in the last release of seam as far as we know.

      so we would like to try this feature using the provided sample.

      We have included in our project the code for the DatabaseResourceBundle and all the related classes.
      According to the attached sample, we have to add :

      resourceBundle.bundleName testBundleName
      resourceBundle.resourceType org.sadun.util.DatabaseResourceBundle
      databaseResourceBundle.bundleName testBundleName
      databaseResourceBundle.connectionString jdbc:mysql://localhost:3308/accountingaudit?user=root&password=root


      in the seam.properties

      in the server.log, I have found those line about that :

      2006-11-23 16:00:01,593 WARN [org.jboss.seam.Component] Component class should be serializable: databaseResourceBundle
      2006-11-23 16:00:01,593 INFO [org.jboss.seam.Component] Component: databaseResourceBundle, scope: SESSION, type: JAVA_BEAN, class: org.sadun.util.DatabaseResourceBundle

      then

      2006-11-23 16:00:01,593 DEBUG [org.jboss.seam.Component] databaseResourceBundle.bundleName=testBundleName
      2006-11-23 16:00:01,593 DEBUG [org.jboss.seam.Component] databaseResourceBundle.connectionString=jdbc:mysql://localhost:3308/accountingaudit?user=root&password=root

      but when I try to use it in a JSF page :

      #{testBundleName.message}

      I got this :

      2006-11-23 16:24:54,093 DEBUG [org.jboss.seam.jsf.SeamVariableResolver] resolving name: testBundleName
      2006-11-23 16:24:54,093 DEBUG [org.jboss.seam.Component] seam component not found: testBundleName

      could help us about that please ?

      there is no error messages so we have no idea why it doesn't work.

      Is there a configuration missing somewhere in order to activate this new functionnality provided by Seam ?

      Thanks in advance for your feedback

      Christophe Laumond,
      Sofware Consultant,
      http://www.m-itc.net

        • 1. Re: Update to Seam i18n to support resource bundle types rel
          smartbinary

          Hello,

          First, note that you need to refer to the seam message component rather than the bundle name in your EL. As such,

          #{testBundleName.message}


          would need to be

          #{messages.message}


          Also, note that Gavin did not implement this multiple resource type support the same way I did in the sample attached to the JIRA. As Gavin notes in his solution,

          I made a one-word change: private -> protected on loadBundle(). You should be able to do anything you like by subclassing now.


          I have not had the opportunity yet to implement the DatabaseResourceBundle support on top of this new seam support.


          Regards,

          Todd

          • 2. Re: Update to Seam i18n to support resource bundle types rel
            gavin.king

            Right, all you need to do is this:


            @Name("resourceBundle")
            public class DatabaseResourceBundle extends ResourceBundle {
             protected java.util.ResourceBundle loadResourceBundle(String name) {
             return ..... ;
             }
            }


            Except .... I just realized that the new scanning code that went into CR1 breaks the ability to override built-in components! Which is a bad bug that I will need to fix for the GA.

            http://jira.jboss.com/jira/browse/JBSEAM-293

            • 3. Re: Update to Seam i18n to support resource bundle types rel
              christophe.laumond

              Thanks to both of you for the feedback.

              Is it possible to define several seam message components ?

              We want to give the possibility to an administrator to change the messages in the application through a webapplication.

              If there is only one seam message component, it won't be very user friendly to display a list of ALL the messages of the application.

              We would like to define one set of messages per page so the user can choose a page and only the messages in this page are displayed.

              This means that we need a seam message component per page.

              Is there a way to do that ?

              Thanks in advance for the feedback.

              Regards,
              Christophe

              • 4. Re: Update to Seam i18n to support resource bundle types rel
                gavin.king

                Seam 1.1 lets you define keys that are scoped to a particular page in myViewId_en.properties.