关闭dataTable
后,我需要您帮助刷新整个dialog
的分页。关闭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();
}
}
答案 0 :(得分:1)
将widgetvar添加到dataTable widgetVar="dtWidgetVar"
然后:
<p:ajax event="close" listener="#{hrd.UpdateDatatable}" update=":Requests:PendingRequests" onComplete="PF('dtWidgetVar').filter()" />
答案 1 :(得分:1)
我希望这会有所帮助:
<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" />
祝你好运!