4 Replies Latest reply on Aug 28, 2009 7:23 AM by allforjava.allforjava.aol.in

    Difference: Collection with and without @DataModel?

    allforjava.allforjava.aol.in
      Hi,

      1. Whats the difference is using the resultList with and without @DataModel? Which one is the good practise?

      Example:

      Scenerio 1: I'll use myEntityQuery.getResultList() in <rich/h:dataTable> to display the result list contents.

      Scnerio 2: I'll use @Model(scope=?) List myResult; and refer it in <rich/h:dataTable>

      The reverse-eng code from database creates view and specific QueryLists, as secnerio 1.   

      2. Any thumb rule how to determine the situations where @out or @DataModel can be used?

      Any related reply will be helpful. Thank you in advance. 
        • 1. Re: Difference: Collection with and without @DataModel?
          swd847

          Do not use @Datamodel if you can possibly avoid it (i.e. if you are using rich:dataTable instead of h:dataTable), with richfaces it is simply not nessesary and adds extra processing overhead.


          • 2. Re: Difference: Collection with and without @DataModel?
            allforjava.allforjava.aol.in

            Thank you Stuart, for speedy reply!


            1.a Can I get the details how the use of @DataModel adds overhead with rich:dataTable?
            1.b And in which scenerios can I use it?


            2. One more query, is it good practise to forward search and pagination status as 'page parameters' towards view with list/colletion?


            Or any way only the search/pagination conditons can be saved in conversation instead of complete resultList?


            • 3. Re: Difference: Collection with and without @DataModel?
              asookazian

              This is the first time I've heard that @DataModel adds overhead significant enough to say don't use it.  It basically wraps your java.util.List or similar collection into ListDataModel which is useful for clickable dataTables.  You can then inject the clicked record using @DataModelSelection.  I've used it very often.


              As an alternative, you can use @Out or simply a getter method to access your List in your JSF page, and then you can pass the current rowIndex using JBoss EL as follows:


              <h:inputText value="foo" action="#{myComponent.bar(baz.getRowIndex())}"/>



              where baz is the value of your dataTable (i.e. the actual List).


              • 4. Re: Difference: Collection with and without @DataModel?
                allforjava.allforjava.aol.in

                I'm really confused! I guess the Seam Team can clarify and guide towards this situation.


                And please clarify/response-to main queries:


                1. Any thumb rule how to determine the situations where @out or @DataModel can be used?


                2. Is it good practise to forward search and pagination status as 'page parameters' towards view with list/colletion?


                3. Any way where only the search/pagination conditons can be saved in conversation instead of complete resultList?


                This will be helpful for me and other.