3 Replies Latest reply on Jun 26, 2012 6:34 AM by healeyb

    problem with update model from a4j:repeat in every time ajax request

    marcusvas

      Hello,

       

      Every time I run an ajax call, the richfaces invokes the method on the model of component a4j:repeat ou a4j:datatable. I just wish the richfaces update the model of these, only when I add them in the list of objects to render.

       

      See below, how can i am doing it:

       

      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

      <html xmlns="http://www.w3.org/1999/xhtml"

          xmlns:h="http://java.sun.com/jsf/html"

          xmlns:f="http://java.sun.com/jsf/core"

          xmlns:ui="http://java.sun.com/jsf/facelets"

          xmlns:a4j="http://richfaces.org/a4j"

          xmlns:rich="http://richfaces.org/rich">

       

       

      <ui:composition template="/template/commonLayout.xhtml">

       

       

          <ui:define name="content">

      <h:outputStylesheet>

              .outhello {

              font-weight: bold;

              }

          </h:outputStylesheet>

          <a4j:region id="rg1">

          <h:form id="form1">

              <h:panelGrid columns="3">

                  <h:outputText value="Name:" />

                  <h:inputText value="#{testeBean.nome}" />

                  <a4j:commandButton value="Say Hello" render="out" execute="@form"  limitRender="true"/>

              </h:panelGrid>

          </h:form>

          <br />

          <a4j:outputPanel id="out">

              <h:outputText value="Hello #{testeBean.nome} !" styleClass="outhello" />

          </a4j:outputPanel>

          </a4j:region>

          <a4j:log />

       

          <a4j:outputPanel id="out2">

       

              <h:outputText value="Data2  #{testeBean.date} !" rendered="true" styleClass="outhello" />

          </a4j:outputPanel>

       

       

         <a4j:outputPanel id="out3">

              <h:outputText value="Data2  #{clienteAction.clientes.size()} !" rendered="true" styleClass="outhello" />

          </a4j:outputPanel>

       

         <a4j:repeat var="c" value="#{clienteAction.clientes}">

              <tr>

                  <td>

                      <h:outputText value="#{c.id}" />

                  </td>

              </tr>

          </a4j:repeat>

       

          </ui:define>

      </ui:composition>

      </html>

       

       

       



       

       

       

      When i click on command button. It just try render e update model from out component and always call the method defined as #{clienteAction.clientes} by a4j:repeat or a4j:datatable component type.

       

      PS: I only have this problem with a4j:repeat or a4j:datatable.

       

      What am i doing wrong? Could someone help me?

        • 1. Re: problem with update model from a4j:repeat in every time ajax request
          healeyb

          Hi, I had a very quick look but I think the problem is that you are using execute="@form", you need to limit this to specific

          component ids, I think. You mention a "list of objects to render" but there doesn't seem to be any such thing, i.e. an EL

          expression that gets a list of components ids from a backing bean.

           

          Maybe execute="out" on the commandButton would help.

           

          Regards,

          Brendan.

          • 2. Re: problem with update model from a4j:repeat in every time ajax request
            marcusvas

            Thanks for the answer. i changed to <a4j:commandButton value="Say Hello" render="out" execute="out"  limitRender="true"/>. Now,    <h:inputText value="#{testeBean.nome}" /> is not submited and the method getclientes of bean until is invoked in every ajax request.

             

            <a4j:repeat var="c" value="#{clienteAction.clientes}" keepSaved="true">

             

            Did not work the solution. Any more suggestions?

             

            Thanks again.

            • 3. Re: problem with update model from a4j:repeat in every time ajax request
              healeyb

              I had another look at this yesterday and the getter is always called in the restore view phase even when not included

              in a partial update as you have said. This is true also for ui:repeat. I don't really know why that is but ui:repeat/a4j:repeat

              is generating markup, so it's probably something to do with that.

               

              So I think that's just how it is, just make sure you are just using IDE generated getters and not doing anything

              expensive like database access.