scott burns wrote the following on 3/17/2005 5:21 PM:
How can I get the index and pass it to a js script function. I tried setting it in my bean but using bean:write is not allowed it seems. Any help would be appreciated.

http://struts.apache.org/userGuide/struts-logic.html#iterate

You need to add indexId
<logic:iterate indexId="indexVal"....

I then like to use regular urls for this kinds of stuff...

<c:url var="url" scope="page" value="/removeAction.do">
    <c:param name="theIndexVal" value="${indexVal}"/>
</c:url>
<a href="${url}"><html:img page="/images/remove.gif"/></a>

ALTHOUGH... I REALLY think you'd be better off doing the remove based on a true id vs the index in the collection. So instead maybe remove based on the product id if it has one?

<c:url var="url" scope="page" value="/removeAction.do">
    <c:param name="productID" value="${lineItem.product.id}"/>
</c:url>
<a href="${url}"><html:img page="/images/remove.gif"/></a>

You also don't need all the nested stuff you could replace..

<nested:root name="lineItem">
>                      <nested:nest property="product">
>                        <nested:write property="name" />
>                      </nested:nest>
>                    </nested:root>

with:

<bean:write property="lineItem.product.name"/>



Scott


<table border="0" width="100%" cellspacing="0" cellpadding="0">
<logic:iterate id="lineItem" name="selectServicesForm" property="lineItems">
<tr>
<td width="10%"><html:text name="lineItem" property="quantity" indexed="true" size="3" maxlength="3" onfocus="select();" /></td>
<td width="50%" align="right">
<nested:root name="lineItem">
<nested:nest property="product">
<nested:write property="name" />
</nested:nest>
</nested:root>
</td>
<td width="20%" align="right">$<bean:write name="lineItem" property="displayPrice" /></td>
<td width="20%" align="center" valign="middle"><html:submit property="action" value="Remove" onclick='test(selectServicesForm,<bean:write name='lineItem' property='index' />);'/></td>


               </tr>


</logic:iterate> </table>

_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today - it's FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/



--------------------------------------------------------------------- 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]



Reply via email to