printx.org

*********** REPLY SEPARATOR  ***********

On 23.11.2005 at 15:06 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]


Mit freundlichen Grüßen

Andreas Bednarz
...........................................
ID.on GmbH
DESIGN and BUSINESS INTELLIGENCE
...........................................
Wagenerstraße 3 | 30169 Hannover
Fon +49(0) 511.93 62 28 - 22
Fax +49 (0)511.93 62 28 - 28
E-Mail [EMAIL PROTECTED]
...........................................
http://www.id-on.de
http://www.e-konfigurator.de





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to