Primefaces对话框-有条件显示它. javascript代码不起作用 [英] Primefaces Dialog box - show it conditionally. javascript code not working

查看:113
本文介绍了Primefaces对话框-有条件显示它. javascript代码不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在单击primefaces命令按钮时显示一个对话框.在对话框之前,我需要检查一个条件.

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

我正在使用Spring web-flow 2.3.0.

I am using Spring web-flow 2.3.0.

所以我是这样做的,

对话框是

基于这种情况,我无法显示此对话框.

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>

对话框是

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

但是,当我单击命令链接时,会出现3个对话框.你能告诉我为什么吗?

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

推荐答案

其他人刚刚发布了相同的问题! :)

Somebody else just posted the same problem! :)

您应该使用oncomplete属性而不是commandButton的onclick.在页面回发之前,将发生click javascript事件,这可能是由于页面重新加载而导致对话框无法显示.

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()"将在回发后显示对话框.

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

这篇关于Primefaces对话框-有条件显示它. javascript代码不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆