jsf - JSF <h :commandButton> 中 PrimeFaces 的 oncomplete 属性

标签 jsf jsf-2

我没有找到 oncomplete在标准 JSF 中的 PrimeFaces 中的某些标签中可用的属性 <h:commandButton> .

如何在使用 <h:commandButton> 时获得类似 oncomplete 的功能?

最佳答案

自素面 oncomplete相当于普通的 JSF success事件(有关更多详细信息,请查看 this answer comments ,您应该按以下方式使用 success 事件:

内联解决方案

<h:commandButton id="someId" action="#{myBean.myAction}">
    <f:ajax onevent="function(data) { if (data.status === 'success') { alert('complete'); }"
        render="whatevet"></f:ajax>
</h:commandButton>

另一个更清洁的解决方案是使用 js 函数
<h:commandButton id="someId" action="#{myBean.myAction}">
    <f:ajax onevent="myJsFunction"
        render="whatevet"></f:ajax>
</h:commandButton>

在你的 js 文件中添加
function myJsFunction(data) {
    if (data.status === 'success') {
         alert('complete');
    }
}

如果您正在寻找一种检测非 ajax 提交完成的方法,您可以从这里采用以下想法 Detecting the File Download Dialog In the Browser

最简单的解决方案是使用
$(document).ready(function () {
// check if some condition is meet and do something...
});

关于jsf - JSF <h :commandButton> 中 PrimeFaces 的 oncomplete 属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15805825/

相关文章:

deployment - 部署 JSF 2.0 项目所需的最低服务器是什么?

css - rich 中的列宽 :datatable

dynamic - 条件jsf包括

java - 王牌 :dataTable search dose not update command button action

css - 如何使用 JSF 嵌入 CSS 背景图像链接?

java - Chrome 在添加另一个 <h :column> 时给出错误 "Extra content at the end of the document"

java - JSF 身份验证和授权

jsf - primefaces IP 地址的输入掩码

jsf - 为什么 p :resetInput require properties of a managed bean to be set to null first after the form is submitted?

java - web.xml 在welcome-file-list 中有不同的文件