title: Blocking a p:commandButton displayed on a p:confirmDialog in addition to displaying a dynamic message on the dialog
body: <p>I'm trying to block a <code>&lt;p:commandButton&gt;</code> which is displayed on a <code>&lt;p:confirmDialog&gt;</code> as follows.</p>
  
  <pre><code>&lt;p:confirmDialog id="confirmDeleteDialog" widgetVar="confirmDelete" message="Message" closeOnEscape="true" appendTo="@(body)" closable="true"&gt;
      &lt;p:blockUI block="confirm" widgetVar="blockUI"&gt;
          &lt;h:outputText value="Demo"/&gt;
      &lt;/p:blockUI&gt;
  
      &lt;p:commandButton id="confirm" value="Yes" onstart="PF('blockUI').show()" oncomplete="PF('blockUI').hide();"/&gt; &lt;!--Use PF('confirmDelete').hide() to dismiss the dialog.--&gt;
      &lt;p:commandButton id="decline" value="No" onclick="PF('confirmDelete').hide()" type="button" /&gt;               
  &lt;/p:confirmDialog&gt;
  
  &lt;p:commandButton oncomplete="PF('confirmDelete').show()"/&gt;
  </code></pre>
  
  <p>This blocks Yes button (one with the <code>id="confirm"</code>) held by <code>&lt;p:confirmDialog&gt;</code>.</p>
  
  <p>The message to be displayed on the confirm dialog is dynamic. It is fetched from the associated backing bean based on certain conditions. Therefore, the dialog is required to be updated before it is displayed.</p>
  
  <p>To update the dialog before it is displayed, the update attribute of <code>&lt;p:commandButton&gt;</code> is set as follows.</p>
  
  <pre><code>&lt;p:commandButton oncomplete="PF('confirmDelete').show()" update="confirmDeleteDialog"/&gt;
  </code></pre>
  
  <p>This of course, displays a desired message on the dialog dynamically (which is not demonstrated here for the sake of simplicity) but doing so prevents the <code>&lt;p:blockUI&gt;</code> from functioning - it does not block the <code>&lt;p:commandButton&gt;</code>, if the dialog is updated by it.</p>
  
  <p>Neither errors on the browser console nor exceptions on the server terminal are seen.</p>
  
  <p>What is the way of blocking a button held by a  in addition to displaying a dynamic message on the dialog?</p>
  
  <hr>
  
  <p><strong>EDIT :-</strong> the answer provided by me is cross-mark.</p>
  
  <p>As noted in the answer given by me, <code>&lt;p/pe:blockUI&gt;</code> needs to be updated, when the <code>&lt;p:commandButton&gt;</code> held by the confirm dialog is clicked, it takes some time to block the button - <code>&lt;p:commandButton&gt;</code> after it is clicked. In the meanwhile, the button can be clicked (either deliberately or  accidently) before the initial request completes that may cause duplicate submits which is certainly against the use of <code>&lt;p/pe:blockUI&gt;</code>.</p>
  
  <p>Nothing is preventing a user in my workaround, from clicking the button multiple times before it is blocked by <code>&lt;p/pe:blockUI&gt;</code>. Therefore, the answer provided by me is considered to be cross-mark.</p>
  
  <p>Perhaps the way to meet this requirement is completely different.</p>
  
  <hr>
  
  <p><strong>EDIT 2:-</strong> the actual scenario.</p>
  
  <pre><code>//A view scoped bean.
  //A list of selected rows in &lt;p:dataTable&gt;.
  private List&lt;WishUtils&gt;selectedValues;
  //The actual message to be displayed on the dialog.
  private String deleteMsg;
  //Associated with the rendered property of the "Yes" button on the dialog.
  private boolean renderedYesButtonDelete=true;
  //The header message/text of the dialog.
  private String messageBoxHeader;
  //The no button text (its value).
  private String noButtonTextDelete="No";
  
  //Getters and setters as required.
  
  public void confirmDelete(ActionEvent actionEvent) {
      if(selectedValues!=null &amp;&amp; !selectedValues.isEmpty()) {
          renderedYesButtonDelete=true;
          noButtonTextDelete="No";
          deleteMsg="A long message about a delete prompt from a resource bundle";
          messageBoxHeader="Confirm Delete";
      } else {
          noButtonTextDelete="OK";
          renderedYesButtonDelete=false;
          deleteMsg="Please select the rows you want to delete";
          messageBoxHeader="Confirm Item Select";
      }
  }
  
  public void delete(ActionEvent actionEvent) {
      if(actionEvent.getComponent().getId().equals("confirmDeleteMultiple")) {
          //Delete the selected rows.
      } else {
          //Notify an error (generally never going to be executed).
      }
  }
  </code></pre>
  
  <p>The message box goes here :</p>
  
  <pre><code>&lt;p:confirmDialog id="confirmDialogDeleteMultiple" widgetVar="confirmDeleteUIWidget" header="#{wishManagedBean.messageBoxHeader}" closeOnEscape="true" appendTo="@(body)" closable="true"&gt;
      &lt;p:blockUI id="blockDelete" block="confirmDeleteMultiple" widgetVar="blockDeleteUIWidget"/&gt;
      &lt;p:remoteCommand name="blockDeleteCommand" update="blockDelete" process="@this"/&gt;
  
      &lt;p:commandButton id="confirmDeleteMultiple" 
                       value="#{messages['confirmdialog.yes']}" 
                       onclick="blockDeleteCommand();" 
                       onstart="PF('blockDeleteUIWidget').show();" 
                       oncomplete="PF('blockDeleteUIWidget').hide();PF('confirmDeleteUIWidget').hide()" 
                       actionListener="#{wishManagedBean.delete}"
                       process="@this"
                       rendered="#{wishManagedBean.renderedYesButtonDelete}"
                       update="a list of components to be updated"/&gt;
  
      &lt;p:commandButton id="declineDeleteMultiple"
                       value="#{wishManagedBean.noButtonTextDelete}" 
                       onclick="PF('confirmDeleteUIWidget').hide()"
                       type="button"/&gt;
  
      &lt;f:facet name="message"&gt;
          &lt;p:outputPanel&gt;
              &lt;h:outputFormat value="#{wishManagedBean.deleteMsg}" escape="false"/&gt;
          &lt;/p:outputPanel&gt;
      &lt;/f:facet&gt;
  &lt;/p:confirmDialog&gt;
  </code></pre>