Here's how I'm doing it:
<table border="3" bordercolor="#323299">
<tr><td></td><td>Permission</td><td>Description</td>
<html-el:form action="/saveuser.do?user=${requestScope.userid}"
type="salesweb.EditUserForm">
<logic:iterate name="edituserForm" property="indexedBeans"
id="indexedBean">
<tr><td><html:checkbox name="indexedBean" property="available"
indexed="true"/></td>
<td><html-el:text name="indexedBean" property="id" indexed="true"
readonly="true"/></td>
<td><bean:write name="indexedBean" property="description"/></td></tr>
</logic:iterate>
</table>
My form contains a getter for indexedBeans that returns an ArrayList, and it
iterates through each item of that storing my custom bean in indexedBean.
IndexedBean has getters and setters for available, id, description. My
action that forwards to this jsp prepopulates all the items.. if oyu want
the checkbox to be checked on viewing the property must be set to "on" "yes"
or one other indicating yes, if you want it to be set to off just leave it
blank. When the form is submitted if its not checked it submits no value at
all.
-David
----- Original Message -----
From: "Gregory F. March" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
Sent: Friday, August 15, 2003 10:48 AM
Subject: html:checkbox, iterate and a value
>
> What is the "proper" way to build html:checkbox's inside of an
> logic:iterate loop?
>
> It seems that the html:checkbox's value parameter can't reference a
> property from the bean of the iterate loop.
>
> I have something close to:
>
> <logic:iterate id="myItem" name="myData" type="...MyData" indexId="index">
> ...
> <html:checkbox indexed="true" property="uniqueKey" name="myItem"/>
> ...
> <html:link action="MyViewItemsAction"
> paramId="myId"
> paramName="myItem"
> paramProperty="uniqueKey">
> <bean:write name="myItem" property="uniqueKey"/>
> </html:link>
> ...
>
> The html:link works great. I just don't know how to achieve the same
> for the checkbox. What I get sent is:
>
> myItem[0].uniqueKey=on
> myItem[1].uniqueKey=on
> myItem[2].uniqueKey=on
>
> Not much of a help. I really need the value of that uniqueKey to be the
> value of the checkbox.
>
> Any help steering me in the right direction would be appreciated.
>
> Thanks!
>
> /greg
>
> --
> Gregory F. March -=- http://www.gfm.net:81/~march -=-
AIM:GfmNet
>
>
> ---------------------------------------------------------------------
> 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]