Jsf 如何基于backbean值有条件地显示PrimeFaces confirmdialog?

Jsf 如何基于backbean值有条件地显示PrimeFaces confirmdialog?,jsf,primefaces,conditional-rendering,confirm-dialog,Jsf,Primefaces,Conditional Rendering,Confirm Dialog,我有一个条件{notificationSearchBean.tooLong}。如果条件为真,我想显示一个confirmDialog,如果条件为假,操作将立即执行,如何创建按钮。当条件为true时,将显示confirmdialog,我希望它正常工作:如果按下Yes,则应执行按钮操作,如果no,则应中止调用。这是我到目前为止所做的,但它需要点击两下才能正确 <h:panelGrid align="center" columns="2" id="bodyContent">

我有一个条件{notificationSearchBean.tooLong}。如果条件为真,我想显示一个confirmDialog,如果条件为假,操作将立即执行,如何创建按钮。当条件为true时,将显示confirmdialog,我希望它正常工作:如果按下Yes,则应执行按钮操作,如果no,则应中止调用。这是我到目前为止所做的,但它需要点击两下才能正确

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


这与基于bean中原始存储内容呈现的按钮不同,但我希望它是当前提交的新值。我如何才能更改此项,使其达到此目的?

可能重复@Mahendranayyarsamykandair,但如果对话框未打开,我希望执行此操作。如果执行中所述操作,则只要
notificationSearchBean.tooLong
为false,搜索操作将永远不会执行。否。您可以有两个类似的按钮,也可以在confirmDialog上有“渲染”属性。p:confirm不能像链接中提到的那样进行渲染,或者使用p:dialog代替actionListener。在侦听器方法中,if(tooLong){RequestContext.getCurrentInstance().execute(“PF('myDialog').show();”);}else{//do regular action}。在对话框“是”按钮中,您将再次执行相应的操作