使用primefaces确认对话框组件显示来自托管bean的消息

Ami*_*ira 2 xhtml primefaces jsf-2

在我的网页,我想点击一个按钮.在确认对话框我使用的属性信息进行显示后显示一个确认对话框,此消息被点击按钮后拍摄值.所以我这样做了:

 <p:commandButton value="Delete" update="testPlanetree" id="deleteBtn" 
   disabled="#{projectTestManagementMB.disable}" oncomplete="deleteConfirmation.show()"
    action="#{projectTestManagementMB.testFn}"/>


 <p:confirmDialog id="confirmDialog" message="# 
  {projectTestManagementMB.deleteConfirmationMsg}"  
    header="Confirming Deleting Process" severity="alert" 
   widgetVar="deleteConfirmation">  

    <p:commandButton id="confirm" value="Yes Sure" update="messages"   
     oncomplete="deleteConfirmation.hide()"    />  

      <p:commandButton id="decline" value="Not Yet" 
       onclick="deleteConfirmation.hide()" type="button" />   

     </p:confirmDialog> 
Run Code Online (Sandbox Code Playgroud)

ProjectTestManagementMB托管Bean:

    private String deleteConfirmationMsg;//with getters and setters 
    public void testFn(){
       deleteConfirmationMsg="do you want to delete ...";
    }
Run Code Online (Sandbox Code Playgroud)

问题是deleteConfirmationMsg 永远不会取值"你想删除..."(总是空的)

任何想法将不胜感激

Bal*_*usC 7

<p:confirmDialog>已经产生的第一个HTTP请求的形式和对话框返回页面它的HTML表示.它只是被CSS隐藏,应该由JS显示/隐藏.当您在bean操作方法中更改确认消息后,只要您不对其进行ajax更新,它就不会反映在生成的HTML输出中.

因此,为了反映已更改的消息,您需要<p:confirmDialog>在显示它之前更新客户端的HTML表示oncomplete.您可以使用update命令按钮的属性来显示对话框.

<p:commandButton ... update="confirmDialog testPlanetree">
Run Code Online (Sandbox Code Playgroud)