<c:forEach var="item" items="${cartitems}" varStatus="status">
<html:text property="cart[${status.index}].unitPrice" value="${item.unitPrice}" /><br>
....
</c:forEach>
Using the nested tag it would be:
<nested:iterate property="cartitems"> <nested:text property="unitPrice" /> <nested:text property="quantity" /> </nested:iterate>
Jim Kennedy wrote:
Just to clarify something. My expectation is that I can generate a form that can grow (row-wise) at runtime and change/modify values in that form. The processing action could then retrieve the dynaform and the changed values would be saved back to whatever (array, collection list...)
-----Original Message-----
From: Jim Kennedy [mailto:[EMAIL PROTECTED] Sent: Wednesday, May 26, 2004 6:52 PM
To: 'Struts Users Mailing List'
Subject: Dynamically sized form using dynavalidator
I have defined a form that will grow dynamically at runtime. The problem I'm having is that the values entered in the form do not save. The form pre-populated just fine. I have an action that delivers the form and another action that processes the form.
Here's the strutsconfig:
<form-bean name="shoppingCartForm"
type="org.apache.struts.validator.DynaValidatorForm">
<form-property name="cart"
type="com.je.common.ShoppingCartItem[]"/> </form-bean>
<action path="/propmgmt/viewcart" type="com.je.struts.action.pm.ViewCartAction" name="shoppingCartForm" scope="session" input="" validate="false"> <forward name="viewcart" path="/tmpl_propmgmt2.jsp?pageleft=/propmgmt/leftmenu.jsp&pagecenter=/pr opmgmt/viewcart.jsp&pagetitle=home.title.key" /> </action> <action path="/propmgmt/checkout" type="com.je.struts.action.pm.CheckOutAction" name="shoppingCartForm" scope="session" input="" validate="false"> <forward name="checkoutform" path="/tmpl_propmgmt2.jsp?pageleft=/propmgmt/leftmenu.jsp&pagecenter=/pr opmgmt/checkout.jsp&pagetitle=home.title.key" /> </action>
========================= Here's the JSP:
<html:form action="/propmgmt/checkout.exe" method="post" scope="session">
<table border="0" width="96%" class="listings">
<tr><th>Shopping Cart Items</th><th>Price</th><th>Length of
Ad</th><th>Item Total</th></tr>
<c:forEach var="item" items="${cartitems}">
<tr>
<td><c:out value="${item.id}" /></td> <td><html:text name="item" indexed="true" property="unitPrice"
size="6" /></td> <td><html:text name="item" indexed="true"
property="quantity"/></td>
<%--<td><html:text name="total" value="" size="7"/></td>--%>
</tr>
</c:forEach>
</table>
<html:submit value="Proceed to Checkout-->"/> </html:form>
Like I said, the form prepopulates but when I enter new values I don't see them in the "checkout" action. The original entered values aren't getting overwritten.
======================================= Here's what the gen'd HTML looks like:
<form name="shoppingCartForm" method="post"
action="/rentworx/propmgmt/checkout.exe">
<table border="0" width="96%" class="listings">
<tr><th>Shopping Cart Items</th><th>Price</th><th>Length of
Ad</th><th>Item Total</th></tr>
<tr>
<td>2702wes8172</td> <td><input type="text" name="item[0].unitPrice" size="6"
value="9.95"></td> <td><input type="text" name="item[0].quantity" value="1"></td>
</tr>
<tr>
<td>30712iv8164</td> <td><input type="text" name="item[1].unitPrice" size="6"
value="9.95"></td> <td><input type="text" name="item[1].quantity" value="1"></td>
</tr>
<tr>
<td>665brya8155</td> <td><input type="text" name="item[2].unitPrice" size="6"
value="9.95"></td> <td><input type="text" name="item[2].quantity" value="1"></td>
</tr>
</table>
<input type="submit" value="Proceed to Checkout-->"> </form>
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
-- Rick
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]