如何使用struts 1的显示标签?

时间:2014-10-11 12:00:54

标签: java displaytag struts1

我想点击按钮删除,我会得到CustomerID并发送给行动。执行功能删除。

<display:table name="sessionScope.CustomerForm.customers" id="row"
        requestURI="/Customer.do" pagesize="15" style="text-align:center"
        excludedParams="_chk" clearStatus="true">
    <display:column title="checkkbox">
        <input type="checkbox" onclick="selectCheckbox();" id="checkBox" />
    </display:column>
    <display:column style="width:500px" property="customerID"
            title="Customer ID" sortable="true" paramId="customerID"
            href="Edit.do">
    </display:column>
    <display:column style="width:300px" property="customerName"
            title="Customer Name" sortable="true" />
    <display:column style="width:300px" property="sex" title="Sex"
            sortable="true" />
    <display:column style="width:300px" property="birthday"
            title="Birthday" sortable="true" />
    <display:column style="width:300px" property="email" title="Email"
            sortable="true" />
    <display:column style="width:300px" property="address"
            title="Address" sortable="true" />
</display:table>
</div>
<br>
<div>
    <html:button styleClass="submit" property="Add new" value="Add New"></html:button>
    <html:button styleClass="submit" property="Delete" value="Delete" ></html:button>
</div>
</html:form>

1 个答案:

答案 0 :(得分:0)

将customerID参数传递给js函数,如下所示:

<display:column title="checkkbox">
        <input type="checkbox" onclick="selectCheckbox(<bean:write value="customerID" />);" id="checkBox" />
    </display:column>

this传递给你的js函数,然后使用js或jQuery导航你的html代码 例如,你可以使用这样的东西:

    function selectCheckbox(element){
             var customerID = $(element).parent().children("td")[1].html();
             // do your stuff!
}