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.
<h:panelGrid align="center" columns="2" id="bodyContent">
<p:commandButton value="Start Search" action="#{notificationSearchBean.getAllNotificationsForQuery}" update="bodyContent" rendered="#{!notificationSearchBean.tooLong}"/>
<p:commandButton value="Start Search" action="#{notificationSearchBean.getAllNotificationsForQuery}" update="bodyContent" rendered="#{notificationSearchBean.tooLong}">
<p:confirm header="Please narrow your search" message="Number of records fetched is #{notification.size}. Would you like to continue?"/>
</p:commandButton>
</h:panelGrid>
<p:confirmDialog global="true" showEffect="fade" hideEffect="fade" >
<p:commandButton value="Yes" type="button" styleClass="ui-confirmdialog-yes" icon="ui-icon-check"/>
<p:commandButton value="No" type="button" styleClass="ui-confirmdialog-no" icon="ui-icon-close"/>
</p:confirmDialog>
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?