Primefaces确认对话框不更新数据表

时间:2017-09-23 09:53:41

标签: primefaces jsf-2 datatable

我想在用户从确认对话框确认操作后更新数据表,但它不起作用。

<p:panel id="formPanel" header="Welcome #{sessionBean.name}">
    <h:form id="dtForm">
        <p:messages id="messages" showDetail="true" autoUpdate="true" closable="true" globalOnly="true" />
        <p:dataTable id="classList" var="class" value="#{listClassBean.classList}"  widgetVar="classListDT"
                     paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                     paginator="true" rows="10" rowsPerPageTemplate="5,10,15" paginatorPosition="bottom"
                     rowKey="#{class.classroomId}" style="margin: 20px 20px 20px 20px;">

            <!--columns omitted-->

            <p:column headerText="Exit" rendered="#{sessionBean.loggedAccount.accType == 'S'}"
                      style="width: 50px; text-align: center;">
                <p:commandButton icon="fa fa-sign-out" action="#{listClassBean.exitClass(class.classroomId)}"
                                 styleClass="redbutton" process="dtForm:classList" update="dtForm:classList">
                    <p:confirm header="Exit Class" 
                               message="Are you sure you want to exit the class #{classroomSettingBean.classroom.classroomId}?" 
                               icon="ui-icon-alert"/>
                </p:commandButton>
            </p:column>
        </p:dataTable>
    </h:form>
</p:panel>

<h:form>
    <p:confirmDialog global="true" showEffect="clip" hideEffect="clip">
        <p:commandButton value="Yes" type="button" styleClass="ui-confirmdialog-yes" icon="ui-icon-check"/>
        <p:commandButton value="No" type="button" styleClass="ui-confirmdialog-no" icon="ui-icon-close" />
    </p:confirmDialog>
</h:form>

一切都表现良好,只是它没有更新数据表。有什么想法吗?

2 个答案:

答案 0 :(得分:0)

您只需在表单和面板之间进行反向,如下所示:

<h:form id="dtForm">
      <p:panel id="formPanel" header="Welcome #{sessionBean.name}">

....

      </p:panel>
</h:form>

答案 1 :(得分:0)

添加 p:remoteCommand 。我有一个相关的问题,这是我如何解决它,只是我用 p:dialog 代替。 textarea更新记录&#34; MyMessage &#34;在 dataTable &#39; myDataTable&#39;。

&#13;
&#13;
<p:dialog header="Customize Message" id="editDlg" widgetVar="displayDlg" modal="true" resizable="false" width="450">
  <p:inputTextarea id="resin" value="#{MyBean.myMessage}" style="width: 400px; height: 150px; padding: 10px; resize: none" maximum="550" />
  <p:commandButton value="Cancel" onclick="PF('displayDlg').hide()" style="width: 75px; left: 220px" /><br/>
  <p:commandButton value="Update" action="#{myBean.updateMyMessage()}" update="form:my_growl" onclick="PF('displayDlg').hide()" style="width: 75px; left: 220px" oncomplete="refreshTable();" />
</p:dialog>
<p:remoteCommand name="refreshTable" action="#{myBean.loadChangedData()}" partialSubmit="true" process="@this, editDlg" update="myDataTable" />
&#13;
&#13;
&#13;