简体   繁体   English

使用struts 1.3以一种形式提交多个

[英]Multiple Submit in one Form using struts 1.3

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. 问题是,actionForm始终提交第一行数据。

I have solved this problem by using javascript: setting in the first row the data of the selected row. 我已经使用javascript解决了这个问题:在第一行中设置所选行的数据。 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. 但是我想知道是否还有其他解决方案,例如在“提交”按钮中使用indexed =“ true”,然后以某种方式获取足够的数据而无需使用JavaScript。

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>

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

your question is unclear without sample code. 没有示例代码,您的问题尚不清楚。

you are probably better off with one form per row. 每行使用一种表格可能会更好。

Is your styleId value (MoreData) the same for all forms of the page? 页面的所有形式的styleId值(MoreData)是否相同? This ends up to be the id attribute of the html form. 这最终是html表单的id属性。 If they are all the same, that might cause problems when submittng the form. 如果它们都相同,则在提交表单时可能会导致问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM