struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rick Reumann <strut...@reumann.net>
Subject Re: Dynamically sized form using dynavalidator
Date Thu, 27 May 2004 04:19:05 GMT
I haven't tested this and it's late.. but your form property is "cart" 
not item.. so if you are going to use JSTL (and not the nested tag which 
is actually easier) it would be something like...

<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:jgkennedy@mindspring.com] 
> 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&amp;pagecenter=/pr
> opmgmt/viewcart.jsp&amp;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&amp;pagecenter=/pr
> opmgmt/checkout.jsp&amp;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: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 


-- 
Rick

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message