Primefaces 如何更新p:对话框中的值并显示在p:对话框中

Primefaces 如何更新p:对话框中的值并显示在p:对话框中,primefaces,dialog,Primefaces,Dialog,我有一个datatable,在最后一列我将有一个编辑操作,它将触发对话框。但是,我发现对话框中的值没有更新。有人能帮忙吗 我的代码如下。事实上,bean.currentItem.name和bean.currentItem.age应该基于我从表中的选择。我检查bean.currentItem是否不为null,并引用我从preEdit方法中选择的内容,但该值从未显示在p:dialog中 <p:dataTable ....> <p:column... <p:co

我有一个datatable,在最后一列我将有一个编辑操作,它将触发对话框。但是,我发现对话框中的值没有更新。有人能帮忙吗

我的代码如下。事实上,bean.currentItem.name和bean.currentItem.age应该基于我从表中的选择。我检查bean.currentItem是否不为null,并引用我从preEdit方法中选择的内容,但该值从未显示在p:dialog中

<p:dataTable ....>
    <p:column...
    <p:column...
    <p:column>
        <f:facet name="header">
            <h:outputLabel value="Update" />
        </f:facet>
            <p:remoteCommand name="preEdit" action="#{bean.preEdit}"
                process="@this" update="@this @form:dlg">
                <f:setPropertyActionListener target="#{bean.currentItem}"
                            value="#{thisItem}" />
            </p:remoteCommand>
            <p:commandLink styleClass="no-decor"
                oncomplete="preEdit();PF('dlg').show();" value="Edit"/>                         
    </p:column>
</p:dataTable>

<p:dialog header="#{lbl.tt_cat_upd}" widgetVar="dlg" id="dlg"
            resizable="false" >
    <h:outputLabel value="#{bean.currentItem.name}" />
    <h:outputLabel value="#{bean.currentItem.age}" />
</p:dialog>


删除您的
p:remoteCommand
并让您的
p:commandLink
为您完成所有工作,怎么样

假设您有一个
h:form
包围着
dataTable
对话框

        <p:commandLink action="#{bean.preEdit}" process="@this" update="dlg" styleClass="no-decor" oncomplete="PF('dlg').show()" value="Edit">
            <f:setPropertyActionListener target="#{bean.currentItem}"
                        value="#{thisItem}" />
       </p:commandLink>


如果您的
数据表
与您的
对话框
格式不同,您可以将
update=“dlg”
替换为
update=“:formIdContainingDialog:dlg”

您好,谢谢您的帮助。它解决了我的问题,但也引发了另一个问题。我添加了另一个列调用delete,delete命令链接将触发p:confirm对话框。当我在p:confirmDialog对话框中单击Yes时,系统从xhtml页面p:dialog字段中抛出NullPointerException。将
rendered=“#{bean.currentItem!=null}”
添加到对话框中如何?