Primefaces onclick和成功的区别 [英] Primefaces onclick and onsuccess differences

查看:79
本文介绍了Primefaces onclick和成功的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下情况:

单击按钮后,将完成一些业务逻辑,完成后,应该会显示一个新的带有报告的标签.

after clicking a button, some business logic is done and after it is done, a new tab with a report should be visible.

<p:commandButton value="this button" update="growlMain"
                 actionListener="#{myBean.businesslogic}" 
                 onstart="ajaxDialog.show();"
                 oncomplete="ajaxDialog.hide();"
                 onsuccess="window.open('./report.jsp', '_newtab');" />

这不起作用:(

如果业务逻辑仅持续几毫秒,则可以执行以下操作:

If the business logic only lasts some milliseconds, the following works:

<p:commandButton value="this button" update="growlMain"
                 actionListener="#{myBean.fastbusinesslogic}" 
                 onclick="window.open('./report.jsp', '_newtab');" />

onclick将打开一个新选项卡,也包括onstart之类的东西,但不适用于onsuccess或oncomplete.为什么?还有持续几秒钟的业务逻辑解决方案吗?

the onclick opens a new tab, also things like onstart but it doesn't work with onsuccess or oncomplete. Why? And is there a solution for business logic that lasts some seconds?

推荐答案

我注意到PrimeFaces命令按钮的onsuccess无效.但是,oncomplete可以工作,并且即使有错误也需要做,例如,即使我的业务逻辑中有错误,在我的情况下也显示成功对话框.尝试使用成功,但不起作用. 您可以尝试使用oncomplete,如下所示:

I have noticed that onsuccess for PrimeFaces command button does not work. The oncomplete however works and does the needful even if there is an error , such as in my case shows a success dialog even if there is an error in my business logic. Tried to use onsuccess but doesn't work. You could try oncomplete as below:

<p:commandButton value="this button" update="growlMain"
                 actionListener="#{myBean.businesslogic}" 
                 onstart="ajaxDialog.show();"
                 oncomplete="ajaxDialog.hide(); window.open('./report.jsp', '_newtab');"/>

这篇关于Primefaces onclick和成功的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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