加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

Primefaces AJAX callbacks: onstart vs. onclick

发布时间:2020-12-16 00:58:10 所属栏目:百科 来源:网络整理
导读:Primefaces AJAX callbacks: onstart vs. onclick I just learned the hard way that onstart and onclick are not the same thing. In particular,a "return ..." has very different semantics in both cases. Consider this code: p:commandLink action="

Primefaces AJAX callbacks: onstart vs. onclick

I just learned the hard way that onstart and onclick are not the same thing.

In particular,a "return ..." has very different semantics in both cases.

Consider this code:
<p:commandLink action="#{bean.method}" onstart="return func()" ...>

If "func()" return false,this code will abort the AJAX request and bean.method() won't get called.
If "func()" returns true,the AJAX request processes.
If you replace onstart with onclick,the AJAX request will abort even if func() returns true.

That's because the Primefaces puts the code to generate the AJAX request in the onclick handler,pre-pending your code from the p:commandLink onclick before it. If your code returns,the AJAX request never gets sent.

http://wrschneider.blogspot.com/2012/01/primefaces-ajax-callbacks-onstart-vs.html

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读