title: How to conditionally display a PrimeFaces confirmdialog based on back bean values?
body: <p>I have a condition `{notificationSearchBean.tooLong}'. How can I create a button when if that condition is true, I want to show a confirmDialog and when its false the action will execute immediately. When the condition is true the confirmdialog is displayed  and I want it to function normally: If Yes is pressed, button action should be executed, if no, the call should be aborted. This is what I have so far but it requires two clicks for it to be correct. </p>
  
  <pre><code>    &lt;h:panelGrid align="center" columns="2" id="bodyContent"&gt;
          &lt;p:commandButton value="Start Search" action="#{notificationSearchBean.getAllNotificationsForQuery}" update="bodyContent" rendered="#{!notificationSearchBean.tooLong}"/&gt;
  
          &lt;p:commandButton value="Start Search" action="#{notificationSearchBean.getAllNotificationsForQuery}" update="bodyContent" rendered="#{notificationSearchBean.tooLong}"&gt; 
              &lt;p:confirm header="Please narrow your search" message="Number of records fetched is #{notification.size}. Would you like to continue?"/&gt;
          &lt;/p:commandButton&gt;
      &lt;/h:panelGrid&gt;
      &lt;p:confirmDialog global="true" showEffect="fade" hideEffect="fade" &gt;
          &lt;p:commandButton value="Yes" type="button"  styleClass="ui-confirmdialog-yes" icon="ui-icon-check"/&gt;
          &lt;p:commandButton value="No" type="button" styleClass="ui-confirmdialog-no" icon="ui-icon-close"/&gt;
      &lt;/p:confirmDialog&gt;
  </code></pre>
  
  <p>This doesn't work as the button rendered based on what was original stored in the bean but I want it to be the new value from the current submission. How can I change this so it does that?</p>