[英]JSF2.0 - Handling erroneous Ajax calls with Primefaces 3.0
我的.xhtml页面中有一个commandButton
:
<p:commandButton action="#{someone.doSomething()}"
ajax="true"
onerror="errorDialog.show();">
</p:commandButton>
它只是在进行Ajax调用。 如何在Ajax调用过程中检测互联网连接问题(客户端/浏览器),超时,会话超时,服务器端异常,崩溃等情况,以便向用户显示信息性消息?
p:ajax
的onerror
属性是否处理所有这些? 如果没有,那又怎样? :)什么是默认超时btw?
任何帮助表示感谢,谢谢。
onerror调用此函数:
onerror(xhr,status,exception) - 当ajax请求失败时要处理的Javascript回调。 采用三个参数,xmlhttprequest,状态字符串和抛出的异常(如果有的话)。
此信息来自文档。 xhr - 实际上是一个请求。 因此,可以找到请求状态和许多其他信息。
<p:commandButton action="#{someone.doSomething()}"
ajax="true"
onerror="console.debug(xhr)">
</p:commandButton>
在chrome或firebug中尝试此代码。 它将显示xhr对象
查看http://primefaces.googlecode.com/files/primefaces_users_guide_3_0.pdf第7.2节Ajax API
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.