【问题标题】:Primefaces confirm dialog not updating datatablePrimefaces 确认对话框不更新数据表
【发布时间】:2018-03-04 20:01:32
【问题描述】:

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

<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>

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

【问题讨论】:

  • 以 jsf 开发模式运行您的应用程序。然后检查您是否收到任何错误。还可以尝试添加p:messages 并让它自动更新,看看它告诉你什么。
  • jsf开发模式下如何运行?并且没有要显示的消息...
  • 它在(好的)jsf 教程中,google abd 更多。从阅读开始stackoverflow.com/tags/jsf/info
  • 尝试上一行

标签: primefaces jsf-2 datatable


【解决方案1】:

添加 p:remoteCommand。我遇到了一个相关的问题,这就是我解决它的方法,只是我使用了 p:dialog 。文本区域更新 dataTable 'myDataTable' 中的记录“MyMessage”。

<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" />

【讨论】:

    【解决方案2】:

    您只需像这样在表单和面板之间进行反转:

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

    【讨论】:

      猜你喜欢
      • 2023-04-03
      • 2014-04-08
      • 1970-01-01
      • 2017-09-07
      • 1970-01-01
      • 2019-02-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多