3 Replies Latest reply on May 2, 2013 12:01 PM by onstottj

    A4j:repeat with multiple input forms

    konami

      Hi,

      I have problem with dealing multiple input forms within a4j:repeat. I have a collection of entities and used a4j:repeat to display the values for editing. The values are displayed correctly, but only the last entity in the collection recognizes the changes and can be saved successfully. The rest of the entity in the collection do not get the changed values when I submit the form.

      Here's the code that is causing problem:

       <a4j:outputPanel rendered="#{applications!=null}" id="searchResults">
       <a4j:repeat id="detail" value="#{applications}" var="item">
       <div class="box">
       <a4j:form>
       <h:messages globalOnly="true"/>
       <div>
       <s:decorate template="../customerInput.xhtml">
       <ui:define name="label">Customer Type</ui:define>
       <h:selectOneRadio id="customerType" layout="lineDirection" value="#{item.customerType}" required="true" >
       <f:selectItem itemValue="new" itemLabel="New"/>
       <f:selectItem itemValue="existing" itemLabel="Existing"/>
       </h:selectOneRadio>
       </s:decorate>
       </div>
       <div style="clear:left;float:left">
       <s:decorate template="../customerInput.xhtml">
       <ui:define name="label">Amount</ui:define>
       <h:inputText value="#{item.amount}"/>
       </s:decorate>
      
       <s:decorate template="../customerInput.xhtml">
       <ui:define name="label">Date</ui:define>
       <h:inputText id="date" size="10" value="#{item.date}">
       <s:convertDateTime pattern="dd/MM/yyyy"/>
       </h:inputText>
       <s:selectDate for="date" dateFormat="dd/MM/yyyy">
       <h:graphicImage url="/img/dtpick.gif" style="cursor:pointer"/>
       </s:selectDate>
       </s:decorate>
       XXXXXXXXXXXXXXXXXXXXXXXX
       XXXXXXXXXXXXXXXXXXXXXXXX
      
       <div class="actionButtons" style="margin: 15px 0px 0px 124px; float: left; clear: left;">
       <a4j:commandButton value="Save" action="#{applicationManager.saveApplication(item)}" reRender="searchResults"/>
       </div>
       </a4j:form>
       </div>
       </a4j:repeat>
       </a4j:outputPanel>


        • 1. Re: A4j:repeat with multiple input forms
          m.a.g

          I've found the same issue. If we use form within a4j:repeat then data from only last form go to backing bean. Here is a simple example:

           <h:panelGroup id="grp">
           <a4j:repeat value="#{bean.items}" var="item">
           <h:form id="frm">
           ${item}:
           <h:inputText id="tst" value="#{bean.test}" />
           <a4j:commandButton value="Go" reRender="grp" />
           </h:form>
           </a4j:repeat>
           </h:panelGroup>
           <a4j:log popup="false" />
          


          @Name("bean")
          public class Bean implements Serializable
          {
           private String test;
           private final List<String> list;
          
           public Bean()
           {
           list = new ArrayList<String>();
           list.add("1");
           list.add("2");
           }
          
           public String getTest()
           {
           return test;
           }
          
           public void setTest(String test)
           {
           System.out.println("setTest(): " + test);
           this.test = test;
           }
          
           public List<String> getItems()
           {
           return list;
           }
          }
          


          I populate edit in the last form with "2222222" and click "Go" button. You can see that request contains the "2222222" value:
          a4j:log output] QueryString: AJAXREQUEST=_viewRoot&j_id5%3A1%3Afrm=j_id5%3A1%3Afrm&j_id5%3A1%3Afrm%3Atst=2222222&javax.faces.ViewState=j_id17&j_id5%3A1%3Afrm%3Aj_id7=j_id5%3A1%3Afrm%3Aj_id7&
          console output] setTest(): 2222222

          I populate edit in the first form with "1111111" and click "Go" button. You can see that request contains the "1111111" value
          a4j:log output] QueryString: AJAXREQUEST=_viewRoot&j_id5%3A0%3Afrm=j_id5%3A0%3Afrm&j_id5%3A0%3Afrm%3Atst=1111111&javax.faces.ViewState=j_id17&j_id5%3A0%3Afrm%3Aj_id7=j_id5%3A0%3Afrm%3Aj_id7&
          console output] nothing, so Bean.setTest() is not called.

          Is it a bug?

          • 2. Re: A4j:repeat with multiple input forms
            m.a.g

            My environment:
            RichFaces 3.2.1 GA
            JSF RI 1.2_07-b03-FCS

            • 3. Re: A4j:repeat with multiple input forms
              onstottj

              I've had the same problem, using Richfaces 3.3.3.  My solution was to move the form out of the a4j:repeat.