tags:

views:

1202

answers:

1

Hi all, In my struts2 application I have an iterator and a list with objects like -

<s:iterator value="listOfObjects">
<tr>
 <td><s:property value="item" /></td>
 <td><s:property value="category" /></td>
 <td><s:property value="quantity" /></td>
 <td><s:property value="brand" /></td>
 <td><s:checkbox name="deleteRow" onclick="submit()"/></td>  
</tr>
</s:iterator>

The above creates a table with a checkbox in the end column of each row. Now, Onclick any checkbox I want to set the values of corresponding row (only) in my bean class. I tried a lot but I am getting values of each row rather that values of only that particuler row whose checkbox user has clicked. Is it possible. If yes then please help. Thanks in advance.

A: 

If the value of the deleteRow checkbox is good enough (based on the toString method of your object), then you should be able to just create a deleteRow property in your Action class with a setter method and parse it out.

I suppose you could set a value expression on the deleteRow checkbox, either using the toString() of the current object, or putting some kind of formatted list (comma separated or something) of the values in there by hand. If you gave the s:iterator an id, you could reference that in the value attribute of the s:checkbox.

Brian Yarger
Not working. Either its setting the values of all beans objects or null. I need to set all values corresponding to the row whose checkbox is checked by user.
vivmal