2
votes

in my page , i'm trying to display a confirmation dialog after clicking a button .In the confirmation dialog i used the attribute message to display it , this message is taken value after clicking the button . So i did it like that :

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

ProjectTestManagementMB Managed Bean :

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

The problem is that the deleteConfirmationMsg never take the value "do you want to delete ..." (is always empty)

Any idea will be appreciated

2
Make sure your setter is exactly like 'setDeleteConfirmationMsg' case-sensitive - Sully
@D3mon: Why would a wrong setter name cause exactly this problem? Even more, is a setter actually mandatory in this case? - BalusC

2 Answers

7
votes

The <p:confirmDialog> has already generated its HTML representation on the very first HTTP request returning the page with the form and the dialog. It's merely hidden by CSS and is supposed to be shown/hidden by JS. When you change the confirm message afterwards in a bean action method, then it won't be reflected in the generated HTML output as long as you don't ajax-update it.

So, in order to get the changed message being reflected, you'd need to update the HTML representation of the <p:confirmDialog> in the client side before showing it in the oncomplete. You can for this use the update attribute of the command button which should show the dialog.

<p:commandButton ... update="confirmDialog testPlanetree">
1
votes

try this i should works :

<p:commandButton value="Delete" update="testPlanetree" id="deleteBtn" actionListener="#
         {projectTestManagementMB.testFn}"
       disabled="# {projectTestManagementMB.disable}" 

       oncomplete="deleteConfirmation.show()"  />