Primefaces Dialog box - show it conditionally. javascript code not working

谁说我不能喝 提交于 2020-01-05 06:55:08

问题


I want to show a dialog box on the click of a primefaces commandbutton. Before the dialog box , I need to check a condtional.

I am using Spring web-flow 2.3.0.

So I am doing it like this ,

And the Dialog Box is

I am not able to show this dialog box based on this condition.

Please help me ,any pointers?

SWF 2.3.0 Primefaces 2.2.1 JSF 2 Spring Security 3 Spring 3.1.0M1I EhCache Apache Tomcat 6.0 STS 2.5.1

So I have changed my code as per below

                    <p:commandLink id="addRequest" immediate="true" value="addreq"
                    oncomplete="dlg3.show()" update="dialogPanel">
                    <f:setPropertyActionListener
                        value="#{searchHandler.selectedAccIns}"
                        target="#{reqSearchHandler.checkAccStatus}" />
                </p:commandLink>

And the dialog box is

                <p:outputPanel id="dialogPanel"
                rendered="#{not reqSearchHandler.accStatusFlag}">
                <p:dialog header="Effect Dialog" widgetVar="dlg3"
                    showEffect="bounce" hideEffect="explode" height="200">
                    <h:outputText
                        value="Account is #{searchHandler.selectedAccIns.accStatusDesc}" />
                    <h:outputText value="Do you want to continue?" />
                    <div align="left">
                        <p:commandButton value="Yes" action="accept" />
                        <p:spacer width="960" height="5" />
                        <p:commandButton value="No" action="cancel" />
                    </div>
                </p:dialog>
            </p:outputPanel>

But when I am clicking on the command link , I am getting 3 dialog boxes. Can you please tell me why it is so?


回答1:


Somebody else just posted the same problem! :)

You should use the oncomplete attribute instead of onclick of the commandButton. The click javascript event occurs before the page posts back, likely causing your dialog not to appear because of the page reloading.

oncomplete="dlg3.show()" will display the dialog AFTER the postback.



来源:https://stackoverflow.com/questions/7281605/primefaces-dialog-box-show-it-conditionally-javascript-code-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!