我有一个问题需要尽快解决,需要你们帮忙。 我有一个带有selectBooleanCheckbox和列过滤的数据表和一个删除按钮(ajax =“false”)。当页面加载时,我按此顺序有五条记录,记录1,记录2,记录3,记录4,记录5.之后,我过滤3.然后我选中复选框并单击删除。但记录1被删除了。
先谢谢!
<td><p:commandButton ajax="false" type="submit"
value="#{msg.rq1001_command_delete}" styleClass="commandButton"
id="rq1001_command_delete"
action="#{pc_Rq1001.doRq1001_command_deleteAction}"></p:commandButton>
</td>
<table>
<tbody>
<tr valign="top">
<td valign="top" width="760"><p:dataTable
styleClass="dataTable" id="rq1001_datatable_request"
value="#{pc_Rq1001.w_request.listrequest}" var="varlistrequest"
rows="50" paginator="true"
paginatorTemplate="{FirstPageLink} {PreviousPageLink} {PageLinks}
{NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
rowsPerPageTemplate="10, 25, 50, 75,100,200"
resizableColumns="true" paginatorPosition="bottom"
filteredValue="#{pc_Rq1001.w_request.listOfFilteredRequest}">
<p:column id="column1" width="20">
<f:facet name="header">
</f:facet>
<p:selectBooleanCheckbox styleClass="selectBooleanCheckbox"
id="rq1001_checkbox_select" value="#{varlistrequest.select}"></p:selectBooleanCheckbox>
</p:column>
<p:column id="column3" width="40" resizable="true"
sortBy="#{varlistrequest.approved_sn}"
style="text-align: left; font-weight : 400"
headerText="#{msg.rq1001_gridheader_approved}">
<h:outputText styleClass="outputGridText" id="text3"
value="#{varlistrequest.approved_sn}"></h:outputText>
</p:column>
<p:column id="column_ID" width="80"
sortBy="#{varlistrequest.requesttradeid}"
filterBy="#{varlistrequest.requesttradeid}"
filterMatchMode="contains" resizable="true"
filterStyle="width:70px"
style="text-align: left; font-weight : 400"
headerText="#{msg.rq1001_gridheader_reqtradeid}"
filterValue="#{varlistrequest.fv_requesttradeid}">
<p:commandLink ajax="false" styleClass="commandLink"
id="rq1001_commandlink_requestid"
action="#{pc_Rq1001.doRq1001_commandlink_requestidAction}">
<h:outputText styleClass="outputGridText_px"
id="rq1001_gridoutput_reqid"
value="#{varlistrequest.requesttradeid}"></h:outputText>
<f:param name="clicked_requestid"
value="#{varlistrequest.requestid}"></f:param>
</p:commandLink>
<f:attribute value="true" name="nowrap" />
</p:column>
<p:column id="column2" width="80"
sortBy="#{varlistrequest.acctcntr_sn}"
filterBy="#{varlistrequest.acctcntr_sn}"
filterMatchMode="contains" resizable="true"
filterStyle="width:70px"
style="text-align: left; font-weight : 400"
headerText="#{msg.rq1001_gridheader_acctcntr}"
filterValue="#{varlistrequest.fv_acctcntr_sn}">
<h:outputText styleClass="outputGridText_px"
id="rq1001_output_acctcntr_sn"
value="#{varlistrequest.acctcntr_sn}"></h:outputText>
<f:attribute value="true" name="nowrap" />
</p:column>
<p:column id="column5" width="60"
sortBy="#{varlistrequest.status_sn}"
filterBy="#{varlistrequest.status_sn}"
filterMatchMode="contains" resizable="true"
filterStyle="width:50px"
style="text-align: left; font-weight : 400"
headerText="#{msg.rq1001_gridheader_status}"
filterValue="#{varlistrequest.fv_status_sn}">
<h:outputText styleClass="outputGridText_px" id="text1"
value="#{varlistrequest.status_sn}"></h:outputText>
<f:attribute value="true" name="nowrap" />
</p:column>
<p:column id="column7" width="80"
sortBy="#{varlistrequest.reqdate}"
filterBy="#{varlistrequest.reqdate}" filterMatchMode="contains"
resizable="true" filterStyle="width:70px"
style="text-align: left; font-weight : 400"
headerText="#{msg.rq1001_gridheader_reqdate}"
filterValue="#{varlistrequest.fv_reqdate}">
<h:outputText styleClass="outputGridText_px" id="text7"
value="#{varlistrequest.reqdate}">
<f:convertDateTime pattern="#{msg.i18n_date_format}" />
</h:outputText>
<f:attribute value="true" name="nowrap" />
</p:column>
<p:column id="column4" width="200"
sortBy="#{varlistrequest.reqdescription}"
filterBy="#{varlistrequest.reqdescription}"
filterMatchMode="contains" resizable="true"
filterStyle="width:190px"
style="text-align: left; font-weight : 400"
headerText="#{msg.rq1001_gridheader_description}"
filterValue="#{varlistrequest.fv_reqdescription}">
<h:outputText styleClass="outputGridText_px" id="text2"
value="#{varlistrequest.reqdescription}"></h:outputText>
<f:attribute value="true" name="nowrap" />
</p:column>
<p:column id="column8" width="200"
sortBy="#{varlistrequest.done_description}"
filterBy="#{varlistrequest.done_description}"
filterMatchMode="contains" resizable="true"
filterStyle="width:190px"
style="text-align: left; font-weight : 400"
headerText="#{msg.rq1001_gridheader_contract_details}"
filterValue="#{varlistrequest.fv_done_description}">
<p:commandLink ajax="false" styleClass="commandLink"
id="rq1001_commandlink_done_description"
action="#{pc_Rq1001.doRq1001_commandlink_done_descriptionAction}">
<h:outputText styleClass="outputGridText_px"
id="rq1001_output_contract_details"
value="#{varlistrequest.done_description}"></h:outputText>
<f:param name="clicked_done_requestid"
value="#{varlistrequest.requestid}"></f:param>
</p:commandLink>
<p:commandLink ajax="false" styleClass="commandLink"
id="rq1001_commandlink_process"
action="#{pc_Rq1001.doRp1001_commandlink_processAction}">
<h:outputText id="text5" styleClass="outputGridText_px"
rendered="#{varlistrequest.processable}"
value="#{msg.rp1001_output_process}"
style="background-color: #0000a0; color: white"></h:outputText>
<f:param name="process_requestid"
value="#{varlistrequest.requestid}"></f:param>
</p:commandLink>
<f:attribute value="true" name="nowrap" />
</p:column>
</p:dataTable>
</td>
</tr>
</tbody>
</table>
public String doRq1001_command_deleteAction() {
String _LOC = "[doRq1001_command_deleteAction]";
// System.out.println(_LOC + "1.0");
if (_w.getListrequest() != null) {
for (Iterator iter = _w.getListrequest().iterator(); iter.hasNext();) {
W_request _wr = (W_request) iter.next();
if (_wr.isSelect()) {
_no_selected = false;
if (_wr.getStatus().equals(ORDER_STATUS_PROCESSED)
|| _wr.getStatus().equals(ORDER_STATUS_LOCKED)) {
_delete_locked_processed = true;
} else {
_w.deleteRequest(_wr.getRequestid());
}
}
}
} else {
showCommonMessage_ByKey("rq1001_message_refresh_list");
return null;
}
if (_no_selected) {
showCommonMessage_ByKey("rq1001_message_delete_no_select");
return null;
} else {
_w.populateRequest();
}
if (_delete_locked_processed) {
showCommonMessage_ByKey("rq1001_message_delete_not_open_locked");
}
return "";
}
答案 0 :(得分:-1)
使用Primefaces select(单个和多个)内置函数。
基本
http://www.primefaces.org/showcase/ui/datatableRowSelectionByColumn.jsf
单
http://www.primefaces.org/showcase/ui/datatableRowSelectionSingle.jsf
多个
http://www.primefaces.org/showcase/ui/datatableRowSelectionMultiple.jsf
即时
http://www.primefaces.org/showcase/ui/datatableRowSelectionInstant.jsf
广播/复选框(我认为这是解决您问题的一种方法)
http://www.primefaces.org/showcase/ui/datatableRowSelectionRadioCheckbox.jsf