3 Replies Latest reply on Aug 29, 2007 10:32 AM by keuller

    Problem with Two DataModel

    keuller

      Hi people,

      I have a seriuos problem with @DataModel at same Managed Bean. I have using Seam 1.2.1 + Ajax4JSF + MyFaces + Tomahawk + Facelets on Tomcat 5.5.23.

      Here is snippet code of my managed bean:

      @Name("servicoBean")
      @Scope(ScopeType.EVENT)
      public class ServicoBean
      {
       @Logger
       private Log log;
      
       @DataModel("categorias")
       private List<Categoria> categorias;
      
       @DataModelSelection("categorias")
       private Categoria categoria;
      
       @DataModel("servicos")
       private List<Servico> servicos;
       ...
      }


      And code of my XHTML page:

      <h:form id="frmCategorias">
       <t:dataTable var="categ" value="#{categorias}" border="0"
       cellpadding="5" cellspacing="1">
       <t:column>
       <t:commandLink value="#{categ.descricao}"
       action="#{servicoBean.selecionaCategoria(categ)}" />
       </t:column>
       </t:dataTable>
      </h:form>
      


      The most curious is the first @DataModel() "categorias" works fine, but the second one "servicos" does not work. Any error is displayed on page, but the data aren't displayed. Is there any patch to correct it or any workaround to solve that ?

      Anyone can help me, please.

      Regards.




        • 1. Re: Problem with Two DataModel
          m.shinde

          First thing don't use Datamodel name and List name same.
          Second define DataModelSelection for Servico.

          Basically DataMOdelSelection used for Clickable Datatable.LIke if you have EDIT/DEL functionality on h:datatable.

          • 2. Re: Problem with Two DataModel
            lucasdeoliveira

            Hi!
            I'm using Jboss Seam, so I'm not sure if it will be as helpfull as u like but I would cut off these Datamodel names. So in resume, try the code below:

            @Name("servicoBean")
            @Scope(ScopeType.EVENT)
            public class ServicoBean
            {
             @Logger
             private Log log;
            
             @DataModel
             private List<Categoria> categorias;
            
             @DataModelSelection("categorias")
             private Categoria categoria;
            
             @DataModel
             private List<Servico> servicos;
             ...
            }
            

            I've done that with JSF+Seam and it works like a charm.

            cheers!

            ps.: If that doesn't help it would be good to post the stack trace so we can take a look at it and see if it's something else.


            • 3. Re: Problem with Two DataModel
              keuller

              Thanks for all tips, but anyone works.

              Below is my modified code:

              @Name("servicoBean")
              @Scope(ScopeType.EVENT)
              public class ServicoBean
              {
               @Logger
               private Log log;
              
               @DataModel
               private List<Categoria> categorias;
              
               @DataModelSelection("categorias")
               private Categoria categoria;
              
               @DataModel
               private List<Servico> servicos;
              
               @DataModelSelection("servicos")
               private Servico servico;
               ...
              }


              I dont change anyXHTML code of "servicos.xhtml" page. The first @DataModel "categoria" works fine and display all data, but second "servicos" does not works again. I use two XHTML pages, the first page called "servicos.xhtml" shows result of "categorias" DataModel object and second page "listServices.xhtml" shows the result of "servicos" DataModel object, but any data is displayed on "listServices.xhtml".

              The action code fired by <t:commandLink /> inside <t:dataTable />:

              ..
              public String selecionaCategoria(Categoria categ)
               {
               log.info("Selecionando a categoria..." + categ.getId());
               this.categoria = categ;
               findServicos();
               return "success";
               }
              ...
              


              I'm using JBoss EL to call this action method. Here is code of "listServices.xhtml" page:

              ...
              <h:form id="frmServicos">
               <t:dataList var="servico" value="#{servicos}" layout="simple"
               preserveDataModel="false">
               <h:outputText value="#{servico.titulo}" />
               </t:dataList>
              </h:form>
              ...
              


              This <t:dataTable /> is empty but there is data in DataModel collection. I have two @Factory objects for each @DataModel object.

              Any suggestion ?

              Regards.