如何在jsf/primefaces ajax请求上设置超时? [英] How to set timeout on jsf/primefaces ajax request?
问题描述
我正在使用 JSF2/Primefaces ,我想知道如何使用jsf或primefaces实现超时回调?
我想使ajax请求的超时时间为30秒,如果请求超时,则可以做为回调.
我将脚放在嘴里,调查了源代码,并谷歌搜索并且第一批点击之一是有关设置超时时间的 PrimeFaces论坛主题. /p>
由于这种结果(奇怪的是我没有提前这样做),我打开了 等...它已经内置了 为了处理错误",有一个onerror事件处理程序,该事件处理程序使用用于基本ajax处理的javascript函数的名称 在这种情况下,要调用服务器端方法,请调用 I am using JSF2/Primefaces and I was wondering how to implement a timeout callback either with jsf or primefaces ? I want to make the timeout for the ajax request 30 seconds and if the request timed out do something as a callback . I put my foot where my mouth is and investigated the source and found a hint. Not to clear but a start so I did some quick Googling and one of the first hits was a PrimeFaces forum topic about setting the timeout As a result of this (weird that I did not do that upfront), I opended the documentation and searched for etc... So it is already built in For acting on the 'error' there is the onerror eventhandler which takes the name of a javascript function for basic ajax handling To call a server-side method in that case call a 这篇关于如何在jsf/primefaces ajax请求上设置超时?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!<p:ajax timeout="30000" onerror="doMyErrorThing" ... />
<p:commandButton timeout="30000" onerror="doMyErrorThing"... />
function doMyErrorThing(...) {
// do your thing
}
p:remoteCommand
,所有方法都应根据您的需要timeout
. Lots of hits and it in the end turned out you could do<p:ajax timeout="30000" ... />
<p:commandButton timeout="30000" ... />
<p:ajax timeout="30000" onerror="doMyErrorThing" ... />
<p:commandButton timeout="30000" onerror="doMyErrorThing"... />
function doMyErrorThing(...) {
// do your thing
}
p:remoteCommand
and all should be as you want it