Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
791 views
in Technique[技术] by (71.8m points)

jsf 2 - Is there any difference between f:ajax and a4j:ajax?

Is there any significant difference between f:ajax and a4j:ajax tags?

I know about a4j:ajax from Richfaces 4 is based on native f:ajax JSF2 tag adding some attributes not found in f:ajax like onbegin, onbeforedoupdate, bypassUpdates, limitRender, status and focus but which one to use when I only need to send a simple ajax request or partial rendering ? Is there performance issues between f:ajax and a4j:ajax?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The <a4j:ajax> tag is just the more convenient form of the basic <f:ajax> tag. You can find a nice overview of all differences in this page.

The execute attribute supports an extra @region value pointing to the <a4j:region>. Any EL in execute and render attributes is resolved in current request instead of in initial request.

The JS function of the onevent attribute of both tags will be invoked 3 times (the passed-in data.status has then the values begin, complete, success). This forces you to use a switch or if when you're only interested in one of them or want to treat them differently. The <a4j:ajax> makes this more convenient with onbegin, onbeforedomupdate and oncomplete attributes respectively. See also this related question: JSF 2: How show different ajax status in same input?

If you're not interested in any of those enhancements, then using <f:ajax> should be perfectly fine as well. The performance difference is (and must be) totally negligible and not be the reason to choose one over the other.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...