6 Replies Latest reply on Oct 6, 2008 11:23 AM by holger_p

    a4j:repeat reRender question

    holger_p

      Hello,

      I have a dynamically list of h:inputText components.When i reRender
      the list , any inputs made by the user which are not saved to the model will be lost.

      If i perform the same operation on a single field , it wil keep its value
      after reRender(even when its not saved to the model - the desired behaviour i need) pls look at the following code

       <h:form id="updateForm">
       <a4j:outputPanel id="updatePanel">
       <h:messages />
      
       <div>
       <!-- will keep the input made by the user after reRender -->
       <h:inputText>
       <f:validateLength minimum="3" />
       </h:inputText>
       </div>
       <a4j:commandLink value="Add Input(no value in backend)" immediate="true" reRender="updatePanel" action="#{testBean.addInput}">
       </a4j:commandLink>
      
       <table>
       <a4j:repeat id="inputRepeat" var="testEntry" value="#{testBean.testEntries}">
       <tr>
       <td>
       <!-- will loose the input made by the user after reRender -->
       <h:inputText>
       <f:validateLength minimum="3" />
       </h:inputText>
       </td>
       <td>
       <h:message for="working" />
       </td>
       <td>
       <a4j:commandLink value="Add Input(no value in backend)" immediate="true" reRender="updatePanel" action="#{testBean.addInput}">
       </a4j:commandLink>
       </td>
       </tr>
       </a4j:repeat>
       </table>
       </a4j:outputPanel>
       </h:form>
      



      What is the reason for this and how to get around this?
      (when i use c:forEach it shows the desired behaviour - but in this case i get duplicated id problems so id like to use a4j:repeat)

      Thx very much,
      Holger


        • 1. Re: a4j:repeat reRender question
          ilya_shaikovsky

          immediate should be false.

          • 2. Re: a4j:repeat reRender question
            holger_p

            Hello ilya,

            Ok what i forget to mention, i need to skip validation that why immediate have to be set to true if i understand this right.


            Well what i need to do is:

            1) generate a list of h:inputText
            2) performan an ajax action which add an input field to that list
            on this action - validation needs to be skipped
            3) reRender the list - all user inputs on the h:inputText have to be saved

            As i already wrote if i use c:forEach i can archieve this goal, but i need to use a4j:repeat to avoid duplicate id problems

            Is this with a4j:repeat possible?

            • 3. Re: a4j:repeat reRender question
              ilya_shaikovsky

              I repeat. With immediate set to true not only validation but apply also will be skipped. So you can't wait that your inputs will be saved. And there is nothing about RF . Just standard JSF behavior.

              Use ajax Single and concrete cells reRender as it shown at repeat richfaces-demo page in order not to reRender not saved inputs.

              • 4. Re: a4j:repeat reRender question
                holger_p

                 


                I repeat. With immediate set to true not only validation but apply also will be skipped. So you can't wait that your inputs will be saved.


                Ok, well i understand this BUT why is this working- it shows that the user inputs are saved on the InputField(not on Bean).
                As u can see in the code the h:inputText has no value property.
                 <c:forEach id="inputRepeat" var="testEntry" items="#{testBean.testEntries}">
                 <tr>
                 <td>
                 <!-- will NOT loose the input made by the user after reRender -->
                 <h:inputText>
                 <f:validateLength minimum="3" />
                 </h:inputText>
                 </td>
                 <td>
                 <h:message for="working" />
                 </td>
                 <td>
                 <a4j:commandLink value="Add Input(no value in backend)" immediate="true" reRender="updatePanel" action="#{testBean.addInput}">
                 </a4j:commandLink>
                 </td>
                 </tr>
                 </c:forEach>
                


                andf this will not
                 <a4j:repeat id="inputRepeat" var="testEntry" value="#{testBean.testEntries}">
                 <tr>
                 <td>
                 <!-- will loose the input made by the user after reRender -->
                 <h:inputText>
                 <f:validateLength minimum="3" />
                 </h:inputText>
                 </td>
                 <td>
                 <h:message for="working" />
                 </td>
                 <td>
                 <a4j:commandLink value="Add Input(no value in backend)" immediate="true" reRender="updatePanel" action="#{testBean.addInput}">
                 </a4j:commandLink>
                 </td>
                 </tr>
                 </a4j:repeat>
                


                Thats what i need understand and then get it to work for a4j:repeat.
                I guess it has something to do with state saving but i am not that jsf expert.
                Well i cant explain it better :-/

                Hope you can help me - if not - well my problem.
                Thx very much,

                Holger



                • 5. Re: a4j:repeat reRender question
                  holger_p

                   


                  ajax Single and concrete cells reRender as it shown at repeat richfaces-demo page in order not to reRender not saved inputs.


                  That a good idea i tried that long time ago(have another posting on this), the problem is that with ajaxKeys u can only reRender existing! rows , but my add action addds a new row which cant be reRender becourse it dont exists.

                  • 6. Re: a4j:repeat reRender question
                    holger_p

                    Hi, its me again,
                    can i have a short statement on my last 2 posts? (if u dont understand what i wrote or what i wanted to ask pls tell me)

                    Thx very much,
                    Holger