views:

173

answers:

3

Hello!

It happens that in my app I throw a lot of data to one logic:iterate, but they need more data, data that is dependent on each row of the iterate. So I thought to put one submit button in each row of the iterate (or maybe a link), so I can redirect the app to the next page. Problem is, the actionForm always submit the first row of data.

I have solved this problem by using javascript: setting in the first row the data of the selected row. But I was wondering if there is any other solution, such as using indexed=”true” in the submit button and then, somehow, getting the adequate data without javascripting it.

Thanks for all!

Edit to add some example code:

<logic:iterate id="MyIterator" name="sql" indexId="index">
<html:form action="MoreData" styleId="MoreData">
<tr>
<td><html:image src="docs/images/more_data.png" property="moreData" indexed="true"/></td>
<td><bean:write name="MyIterator" property="cod_user"/></td>
<td><bean:write name="MyIterator" property="txt_user"/></td>
<td><bean:write name="MyIterator" property="date_born"/></td>
<td><bean:write name="MyIterator" property="id_number"/></td>
</tr>
</html:form>
</logic:iterate>
+1  A: 

<input type="submit" name="btn[]" value="loopVarible"/> <input type="submit" name="btn[]" value="loopVarible" />

Deepak
I understand that with indexed="true" y have something on the lines of <input type="image" value="More Data" src="img/moreData.png" name="moreData[0]"><input type="image" value="More Data" src="img/moreData.png" name="moreData[1]"> etc...The question goes on other lines, such as how can I retrive the exact data of the selected row in my Action?
Random
+1  A: 

your question is unclear without sample code.

you are probably better off with one form per row.

irreputable
Added some sample code. My problem is that when I call the 'moreDataAction' (defined in strut-config) it always brings me the first row. I added the parameter indexed="true" so now it parses in html as "moreData[0]", but I don't know how to use it to bring the specific data to my action.
Random
+1  A: 

Is your styleId value (MoreData) the same for all forms of the page? This ends up to be the id attribute of the html form. If they are all the same, that might cause problems when submittng the form.

svachon
That's part of the problem. Becouse the form is inside the iterate, it creates sql.size forms with the id="MoreData", and then it submits the first one (as is it the first found in the html code). I thought I could do something with the indexed attribute, though.
Random