使用显示标记从JSP页面的一行中获取价值 [英] Get value from a row in a JSP page using display tag

查看:68
本文介绍了使用显示标记从JSP页面的一行中获取价值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

很抱歉有一堆Struts2/JSP问题,但是我有一个用显示标签生成的表:

Sorry for a bunch of Struts2 / JSP questions, but I have a table generated with Display tag:

<display:table name="table" pagesize="10" id="row" requestURI="">
<display:column title="Action">
    <s:form theme="simple">
        <s:submit action="remove" value="Remove" 
        onclick="return confirm('Are you sure you want to delete this item?');"/>
        <s:submit action="displayEdit" value="Edit"/>
    </s:form>
</display:column>
<display:column property="cpc" title="CPC"/>
<display:column property="companyName" title="Company Name"/>
<display:column property="eventType" title="Event Type"/>
<display:column property="industryType" title="Industry Type"/>
<display:column property="previousEvents" />
<display:column property="creditNotifications" />
<display:column property="interimNotifyEnterprise" />
</display:table>

现在,我希望能够删除或编辑某一行(我已经写出了动作),但是如何获取每一行的特定数据,所以我可以告诉Action类要编辑或删除的行?

Now I want to be able to delete or edit a certain row (I already have the actions written out), but how would I get the specific data for each row so I can tell my Action class which row to edit or delete?

推荐答案

我在之前的

I mentioned this in the previous question you asked the other day. You just need to something in your row, possibly a hidden field, that can be used to uniquely identify the item.

我建议在行中使用<s:hidden key="rowID" />,它将随动作一起提交.只要您在对象上具有类似的属性,并且在remove动作中,您就有一个可以接收该值的设置器,就可以使用该值唯一地标识该行.

I suggested using an <s:hidden key="rowID" /> in the row, which would get submitted with the action. As long as you had a property like that on your object, and in the remove action, you had a setter to receive that value, you could use that to uniquely identify the row.

这篇关于使用显示标记从JSP页面的一行中获取价值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆