我需要你的帮助在我关闭dialog
后用分页刷新整个dataTable
。使用当前代码关闭dialog
后,如果所选项目在第一页并且我可以看到更新,则dataTable
将刷新。
但是,如果我使用过滤器搜索了一个特定的项目,然后我单击视图图标来查看对话框,然后关闭dialog
。dataTable
将不会刷新,除非我从过滤器中删除搜索项,然后我试图再次搜索它,我将找到更新。
页面的代码是:
<h:form id="Requests">
<p:dataTable id="PendingRequests"
var="hr"
value="#{hrd.pendingRequests}"
paginator="true"
rows="15"
paginatorTemplate="{RowsPerPageDropdown} {FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink}"
rowsPerPageTemplate="5,10,15"
paginatorPosition="bottom"
filteredValue="#{hrd.filteredPendingRequests}">
<p:column headerText="Req. No." sortBy="#{hr.reqNo}" filterMatchMode="contains" filterBy="#{hr.reqNo}">
<h:outputText value="#{hr.reqNo}"/>
</p:column>
<p:column headerText="Print Count" filterMatchMode="contains" filterBy="#{hr.printCount}">
<h:outputText value="#{hr.printCount}"/>
</p:column>
<p:column>
<f:facet name="header">View</f:facet>
<p:commandButton id="submitbutton"
update=":Requests:#{hr.dialogueName} "
oncomplete="PF('#{hr.certificateDialogue}').show()"
title="View">
<f:setPropertyActionListener value="#{hr}" target="#{hrd.selectedRequest}"/>
</p:commandButton>
</p:column>
</p:dataTable>
</h:form>
dialog
的代码是:
<p:dialog id="employmentCertificateDialog"
header="Certificate"
widgetVar="employmentCertificateDialog"
modal="true"
showEffect="fade"
hideEffect="fade"
resizable="true">
<p:ajax event="close"
listener="#{hrd.UpdateDatatable}"
update=":Requests:PendingRequests"/>
</p:dialog>
UpdateDatatable()
方法的代码是:
public void UpdateDatatable(CloseEvent event) {
listPendingRequests = new ArrayList<PendingRequests>();
try {
//Select Statement
while (result.next()) {
PendingRequests pendingList = new PendingRequests();
reqNo = result.getString("REQ_SEQ_NO");
printCount = result.getString("DOC_PRINTED_CNT" + 1);
pendingList.setReqNo(reqNo);
pendingList.setPrintCount(printCount);
}
} catch (Exception e) {
e.printStackTrace();
}
}
添加widgetvar到数据表widgetVar="dtWidgetVar"
然后:
<p:ajax event="close" listener="#{hrd.UpdateDatatable}" update=":Requests:PendingRequests" onComplete="PF('dtWidgetVar').filter()" />
希望对您有所帮助:
<p:dialog id="dialog-test" onHide="refreshTable();">
...
</p:dialog>
放置在页面末尾:
<p:remoteCommand name="refreshTable" action="#{hrd.UpdateDatatable}"
partialSubmit="true" process="@this" update="Requests" />
如果你需要从你的对话框发送信息到backBean,也许你需要改变过程,添加对话框id或你想要发送的元素id:
<p:remoteCommand name="refreshTable" action="#{hrd.UpdateDatatable}"
partialSubmit="true" process="@this, dialog-test" update="Requests" />
祝你好运!