在 primefaces 中,我有一个确认对话框,当我确认删除按钮时,我在数据库中的行被删除,但页面没有更新。我是否缺少不更新页面的内容。我的对话框定义如下。
<h:form id="searchForm">
<p:commandButton id="showDialogButton" value="Delete Data" onclick="confirmation.show()"
style="margin:20px" type="button" immediate="true" />
<p:confirmDialog id="confirmDialog" message="Are you sure you want to delete all the data for this submission?"
header="Initiating delete process" severity="alert" widgetVar="confirmation">
<p:commandButton id="confirm" value="Yes Sure" update=":searchForm:rowDataTable" oncomplete="confirmation.hide()"
actionListener="#{myDataBean.deleteData}" immediate="true" ajax="true"/>
<p:commandButton id="decline" value="Not Yet" onclick="confirmation.hide()" type="button" immediate="true"/>
</p:confirmDialog>
以相同的形式,我定义了一个数据表
<p:dataTable var="row"
value="#{myDataBean.entries}"
id="rowDataTable" paginator="true"
rows="30"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
rowsPerPageTemplate="10,20,30"
>
其中有一个显示所有数据的子表
<p:subTable id="rowSubTable" var="details" value="#{row.data}">
在我的 bean 中,我有以下动作监听器。动作侦听器完成后,它调用加载初始视图方法来重新加载数据,因为我已经定义了预渲染视图事件。
public List<SubmissionRow> entries = new ArrayList<SubmissionRow>();
public void loadInitialView() {
if (!postback) {
List<Submission> data = loadData();
//sort data and build entries list
}
}
@Transactional
public void deleteData(ActionEvent actionEvent) {
submission.deleteRows(submissionBean.getSubmission());
entries.clear();
postback = false;
}