5 Replies Latest reply on Oct 12, 2007 2:01 AM by lcoetzee

    DataModel in two SFSB issues (regression)

    lcoetzee

      Hi,

      some time ago I ran into this problem (which was fixed in CVS), but seems to have re-appeared with Seam 2.0 CR2

      http://www.jboss.com/index.html?module=bb&op=viewtopic&t=106625

      Briefly...
      I have a SFSB (questionnaireManagementBean) where I create/populate a datamodel ("sections"), which is outjected and used on my xhtml page. From that page (in the same conversation) I execute a method in another SFSB (sectionManagementBean)(where I use the previously outjected datamodel). At this point the datamodel is not available in sectionManagementBean anymore (in previous CVS builds this variable was available (but I dont know when this stopped working again)).

      The source code:

      @Stateful
      @Name("questionnaireManagementBean")
      public class QuestionnaireManagementBean implements QuestionnaireManagement {
      
       @DataModel
       private List<Section> sections;
      
      .
      .
      .
      }
      


      @Stateful
      @Name("sectionManagementBean")
      public class SectionManagementBean implements SectionManagement {
       @DataModel(value="sections")
       private List<Section> sections;
      
       @DataModelSelectionIndex(value = "sections")
       private int selectedSectionNr;
      .
      .
      }


      When I look at the variables in the conversation context injected into the sectionManagementBean I see the "sections" in the conversation context as:
      INFO[csir.questionnaire.management.seam.SectionManagementBean] questionnaireManagementBean.sections


      and not as just a normal "sections". Thus the variable is null (which results in all sorts of nasty things.)

      Any suggestions ?

      Thanks

      Louis


        • 1. Re: DataModel in two SFSB issues (regression)
          pmuir

          You were using unintentional behaviour in Seam. I fixed this properly a while ago.

          What you need to do is inject the values in the second bean:

          @Stateful
          @Name("sectionManagementBean")
          public class SectionManagementBean implements SectionManagement {
           @In("#{sections.wrappedData}")
           private List<Section> sections;
          
           @In("#{sections.rowData}")
           private int selectedSectionNr;
          .
          .
          }


          • 2. Re: DataModel in two SFSB issues (regression)
            lcoetzee

            Great stuff. Thanks Pete.


            (I will have to update my code in a few places where I have used this behavior, but not a big problem)

            A quick test showed that it needs to be :

            @In("#{sections.wrappedData}")
             private List<Section> sections;
            
            @In("#{sections.rowData}")
            @Out(required = false, scope = ScopeType.CONVERSATION)
            private Section section;
            


            and seems I dont need:
            section = sections.get(selectedSectionNr);
            anymore


            Thanks

            L

            • 3. Re: DataModel in two SFSB issues (regression)
              lcoetzee

              One question regarding:

              @In("#{sections.rowData}")
               @Out(required = false, scope = ScopeType.CONVERSATION)
               private Section section;
              


              Is there a way that one can say .. required=false using the above annotation. At this point I get an exception when I try to use execute another method in the sectionManagementBean (without me actually choosing an element from the datamodel).

               handling uncaught exception
              javax.servlet.ServletException: #{sectionManagementBean.manageSections}: javax.ejb.EJBTransactionRolledbackException: Error reading 'rowData' on type org.jboss.seam.jsf.ListDataModel
              



              Thanks

              L


              • 4. Re: DataModel in two SFSB issues (regression)
                pmuir

                @In(value="...", required=false) - value is the "defualt" attribute for an annotation

                • 5. Re: DataModel in two SFSB issues (regression)
                  lcoetzee

                  Thanks Pete... my Eclipse code completetion, combined with the "default value" tripped me up a bit.

                  Thanks

                  L