Reputation: 234
I have displayed a table using struts iterator tag. Now every row has an edit link at the end. I need to be able to send that row into action when the edit button is clicked .
But I am unable to understand how to do that. I have
<s:form action="/execute" id="frm" name="frm" method="POST">
<table style="width: 800px; ">
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>Actions </th>
</tr>
</thead>
<s:iterator value="listToIterate" var="row" status="stat" begin="0" >
<tbody>
<tr>
<td><s:property value="ID" /></td>
<td><s:property value="Name" /></td>
<td><s:a href="#" onclick="document.forms['frm'].submit();">
edit<s:param name="Name" value="%{#row[2]}"/></s:a></td>
</tr>
</tbody>
</s:iterator>
</table>
</s:form>
Using the param tag I want to set the row as a parameter so that I can retrieve it in my action . How do I do this ?
Upvotes: 0
Views: 1342
Reputation: 10458
Assuming your form is displaying id's correctly... then substitute your s:a with one following this form:
<s:a namespace="/yournamespace" action="the-edit-action">
edit<s:param name="ID" value="ID"/>
</s:a>
I would rather ID be called id. the-edit-action will need a getter and setter for id.
Upvotes: 1