如何使用struts提交按钮在迭代列表中提交对象的特定ID?
<s:form action="actionDeleteBooking">
<s:iterator var = "bookingList" value="bookings">
<s:submit label="delete booking" value = "cancel booking" theme = "simple" id="bookingid" />
</s:iterator>
</s:form>
如果是单选按钮,我可以这样做:
<s:form action="actionConfirmBooking">
<s:iterator var = "pathList" value="results">
<s:iterator var = "flightList" value="pathList">
<s:radio name="flightSelected" list="flightList" listKey = "flightid" id = "flightid" value = "flightid"/>
</s:iterator>
</s:iterator>
<s:submit label="Submit" />
</s:form>
答案 0 :(得分:2)
如果您要实现的目标是为每个&#34;行&#34;提交一个提交按钮,提交一个值,然后使用多个表单和一个隐藏字段:
<s:iterator var = "bookingList" value="bookings">
<s:form action="actionDeleteBooking">
<s:hidden name="selectedItem" value="%{bookingid}" />
<s:submit label="delete booking" value="cancel booking" theme="simple" />
</s:form>
</s:iterator>
否则使用<s:a />
,或使用JavaScript设置字段,或者更好地描述您想要的内容。
答案 1 :(得分:1)
您可以对要删除的项目使用checkbox
标记。您应该可以这样做,因为您已经使用了与s:radio
类似的表单。
<s:form action="actionDeleteBooking">
<s:iterator var = "bookingList" value="bookings">
<s:checkbox name="bookingids" label="bookingid" />
</s:iterator>
<s:submit label="delete bookings" value = "cancel booking" theme = "simple"/>
</s:form>