7 Replies Latest reply on Oct 2, 2008 3:04 PM by Johan Nilsson

    reRender and consultations to the database

    Juan Ardissone Newbie

      Hi.


      I have two rich:datatable into a page.xhtml and an a4j:commandButton with reRender pointing to a secondTable and I found both SELECTs when I click the button.


      If I have the reRender pointing to the second table, why the SELECT of the first datatable is execute too?

        • 1. Re: reRender and consultations to the database
          Joshua Jackson Master

          Because the value of the referenced object has changed. Try making it into two different objects in your Action class. One for the datatable, the other one for the select, Hopefully it works.

          • 2. Re: reRender and consultations to the database
            Juan Ardissone Newbie

            Thanks for reply Joshua.


            What do you mean for two different objects in the action class? There are two separated metods. And I use the datatable like this
            rich:dataTable with the value binding to test.consultas and the onother one binding to test.avisos



            //-- @Name(test)
            
            public List<Aviso> getAvisos() 
            {
              if (avisos == null) 
              {
                avisos = oferenteSubasta.getDefinedInstance().getAvisos();
              }
            }
            
            public List<Consulta> getConsultas() 
            {
              if (consultas == null) 
              {
                consultas = oferenteSubasta.getDefinedInstance().getConsultas();
              }
            }


            • 3. Re: reRender and consultations to the database
              Juan Ardissone Newbie

              Sorry I forgot the returns into the two metods. There is a return avisos and a return consultas at the end of the metods.

              • 4. Re: reRender and consultations to the database
                Stefano Travelli Newbie

                Maybe you haven't enclosed the two table in two different a4j:region so that they are both decoded on the server for each request.


                If this is the case, try looking at a4j:region and a4j:outputPanel in the RichFaces doc.

                • 5. Re: reRender and consultations to the database
                  Juan Ardissone Newbie

                  I tried that Stefano. but is the same.


                  <a4j:region id="commonRegion2">
                          <a4j:outputPanel id="panelConsultas">
                                  <rich:dataTable value="#{prueba.consultas}" 
                                                var="o" 
                                         rowClasses="rvgRowOne,rvgRowTwo"
                                                 id="consultasTable"
                                              style="width: 600px;">
                                          <rich:column>
                                                  <f:facet name="header">Consultas</f:facet>
                                                  #{o.id}
                                          </rich:column>
                                          <rich:column>
                                                  <f:facet name="header">Titulo</f:facet>
                                                  #{o.titulo}
                                          </rich:column>
                                  </rich:dataTable>
                          </a4j:outputPanel>
                  </a4j:region>
                  
                  <a4j:region id="commonRegion">
                          <a4j:outputPanel id="panelAvisos">
                                  <rich:dataTable value="#{prueba.avisos}" 
                                                var="o" 
                                         rowClasses="rvgRowOne,rvgRowTwo"
                                                 id="avisosTable"
                                              style="width: 600px;">
                                          <rich:column>
                                                  <f:facet name="header">Avisos</f:facet>
                                                  #{o.id}
                                          </rich:column>
                                          <rich:column>
                                                  <f:facet name="header">Titulo</f:facet>
                                                  #{o.titulo}
                                          </rich:column>
                                  </rich:dataTable>
                          </a4j:outputPanel>
                  </a4j:region>
                  



                  My Button is here


                  <a4j:form ajaxSubmit="true" id="form1">
                          <a4j:commandButton value="Actualizar Avisos"
                                              id="btnActualizarAvisos" 
                                              reRender="panelAvisos">
                          </a4j:commandButton>
                  </a4j:form>
                  



                  LOG



                  14:45:04,765 INFO  [Prueba] OBTENIENDO CONSULTAS...
                  14:45:04,765 INFO  [STDOUT] Hibernate: select subasta0_.id...
                  14:45:04,812 INFO  [STDOUT] Hibernate: select consultas0_.subasta_id...
                  14:45:04,812 INFO  [Prueba] OBTENIENDO AVISOS...
                  14:45:04,859 INFO  [STDOUT] Hibernate: select avisos0_.subasta_id...
                  




                  • 6. Re: reRender and consultations to the database
                    Juan Ardissone Newbie

                    Hi. Anyone know what's wrong with this code?

                    • 7. Re: reRender and consultations to the database
                      Johan Nilsson Newbie

                      I'm having the exact same error. Does anybody know a solution? aka bump


                      Thanks in advance!