问题描述
我有以下情况:
点击一个按钮后,一些业务逻辑就完成了,完成后,一个带有报告的新标签应该是可见的.
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 也能正常工作并执行必要的操作,例如在我的情况下,即使我的业务逻辑中存在错误,也会显示成功对话框.尝试使用 onsuccess 但不起作用.您可以尝试如下完成:
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 和 onsuccess 差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!