PrimeFaces Ajax Callbacks [ (xhr, status, args) ]

PrimeFaces partial page rendering feature is powered by JSF 2.0′s standard Ajax APIs with some of our own extensions. One of these extensions is the client side callbacks for ajax request, standard f:ajax has onerror and onevent whereas PrimeFaces provides onerror, onsuccess, onstart and oncomplete so when do these callbacks are executed?

onstart()
Before the ajax request is sent, xhr object is passed as a parameter and if you return false you can cancel the request. Also if the component that fires the ajax request supports onclick, that would be an alternative.

onerror(xhr, status, exception)
Fired when something goes wrong on server side, it gets three parameters xhr is the request object, status is the status response as string and exception is the object containing detailed information about the error.

onsuccess(xml)
Executed when server returns the partial output in xml format but before it is processed for dom update, this is handy if you’d like to parse the xml in your own. If you return false, you can cancel default dom update process.

oncomplete(xhr, status, args)
This is the most popular callback that is used, fired when response is received and dom is updated, it gets three parameters, xhr is the request object, status is the response status as string and args is the optional callback parameters that are passed from server as JSON using PrimeFaces RequestContext API. I’ll create a detailed post about how to use the handy args feature soon.


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值