Thank you for your reply.  So in your ActionForm you have a List
property called cartEntries? And the struts populating mechanism is
aware of this because you have the [] characters in the textbox name,
right? And the cartEntries list contains a CartEntry object which has a
productCount property, and the struts populating mechanism puts the
value submitted by the textbox in the productCount property? What
advantage is gained, if any, by using the html:text tag, instead of just
using an html input type="text" tag? I have so far preferred using jstl
only in my view layer.

For your delete from cart functionality, you have a link to delete the
object. The view layer specification i am working with requires a
checkbox, so that multiple records can be deleted at once, by clicking
the update cart button. Since the checkbox only submits a value if it is
checked, do you know what will happen if the struts populate mechanism
receives set of request parameters that point to a list backed property,
when the request parameters' indexes are not consecutive?

Thanks for you help

Dave 



On Wed, 2005-11-23 at 15:06 +0100, Danny Lee wrote:
> Here's a snippet from my checkout.jsp:
> 
>   <c:forEach var="item" items="${checkOutForm.cartEntries}" 
> varStatus="status">
> 
>   <c:if test="${status.index%2==1}">
>        <TR  bgcolor="#ECECFF">
>        </c:if>
>         <c:if test="${status.index%2==0}">
>        <TR bgcolor="#FFECFA">
>        </c:if>        
>        <TD><A href="../showProduct.do?id=${item.productID}">
>       <IMG src="images/product_pix/${item.productID}_mini.jpg" border=0 
> align=left height=40></a></TD>
>          <TD><font face="Verdana" size="2">   <c:out 
> value="${item.productName}"/></TD>
>          <TD><font face="Verdana" size="2">   <fmt:formatNumber 
> value="${item.productPrice}" type="currency" currencySymbol="&euro;"/></TD>
>          <TD><font face="Verdana" size="2"><b>x</b> <html:text
>                     property="cartEntries[${status.index}].productCount"
>                     value="${item.productCount}"
>                     size="1"/></TD><TD align="left"><html-el:link
>  
> href="../CheckOut.do?DIALOG-EVENT-DELETE&productID=${item.productID}">
>              <html:img src="../jsp/images/trash.gif" border="0" 
> align="left"/>
>              </html-el:link></TD>
>              </TR>
>      </c:forEach>
> 
> Well, you see, it's quite easy :) The only thing I have to do after user 
> submitting the data, is to persist the given cartEntries[].productCount, 
> becouse my shoppingcart is in the database (which is more safe and easer 
> to analye with some stastic apps later).
> 
> Chhers,
> 
> Danny
> 
> P.S. And yes, I use Struts Dialogs :)
> 
> 
> David Evans schrieb:
> > Sorry, I've search for hours but can't seem to find the answer to this
> > basic problem.
> > 
> > I'm building a shopping cart for the first time in struts. I have a
> > display cart jsp that will show each item, and as expected, i have a qty
> > textbox for each item and an update cart button. so each qty field will
> > have to have, as part of its name, an id to tie it to the particular
> > item in the cart. there is another field in each row, a "remove"
> > checkbox, so i can't just name it the id. the cart hangs out in the
> > session scope, and has a List of CartItem objects called "items".  the
> > action, when called to show the cart, will call cart.getItems() and
> > stick the List in the request, so that it can easily be referenced by
> > the c:foreach tag that i will be using to create the html. So the only
> > way i can figure to get those qty fields in the request to be set in the
> > ActionForm, upon form submission, is to use a map in the ActionForm,
> > since i won't know how many items there will be. So the ActionForm ends
> > up with all of the qty fields in the map, with the key being the name
> > attribute from the textbox, and the value being the quantity typed in by
> > the user. So in the action upon form submission i can iterate through
> > the keys, filter out all keys that start with "qty" and update the qty
> > for those items.
> > 
> > So this seems a little hackish, i was wondering if there's a better way,
> > and secondly, what exactly do i have to name those textboxes to get
> > struts to recognize that they are pointing to a Map. I'm guessing that
> > it will be mapname.key, is that correct?
> > 
> > Dave
> 
> 
> ---------------------------------------------------------------------
> 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]

Reply via email to