File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSF and the fly likes h:form vs a4j:form Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "h:form vs a4j:form" Watch "h:form vs a4j:form" New topic

h:form vs a4j:form

Muneeswaran Balasubramanian
Ranch Hand

Joined: Mar 19, 2010
Posts: 138
Hi to all,
I am new to jsf.I am trying to write code in jsf. i so confused with h:form and a4j:form.So I need a difference between h:form and a4j:form.Up to my knowledge,
a4j:form is used for ajax request.It converts non-ajaxable component like a h:commandbutton to ajaxable component.Please give any other difference between the above two.
Thanks in advance.

Cheers Munees
My Blog
Bart Kummel
Ranch Hand

Joined: Nov 30, 2007
Posts: 81
Hi Muneeswaran,

In my humble opinion, the use of Ajax4JSF isn't needed any more. I think you'll be better of by using components that have AJAX functionality embedded. Take a look at the MyFaces Trinidad component set for example. They already have AJAX embedded in the components.

That set, most component sets (Trinidad included) have their own "form" component. The best thing to do is to choose a single component set for your project and use that set for everything. Then you can use that component set's form component on all your pages.

I hope this will help you with your first steps on the JSF path.

Best regards,
Bart Kummel

SCJP 1.4 | SCJD 1.6 | Visit my website | Author of the book Apache MyFaces 1.2 Web Application Development
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17417

According to the RichFaces docs, the a4j:form is "almost never" needed anymore. Unfortunately, they're not very specific on what the few remaining cases are. Originally it provided AJAX support that is now done transparently. Although I experimented with a4j:form when I had some very sticky problems, I don't recall any problems that actually were solved by using a4j:form instead of h:form.

I think you're incorrect on the ability for an a4j form to "convert a commandButton". The attributes of the h:commandButton are not extensible, so the only AJAX support a plain commandButton should have is the same level that a straight (non-JSF) HTML commandButton has. The a4j:commandButton adds extra AJAX-supportive features like the reRender attribute, but it's a distinct tag precisely because JSF tags are not directly extensible.

An IDE is no substitute for an Intelligent Developer.
Muneeswaran Balasubramanian
Ranch Hand

Joined: Mar 19, 2010
Posts: 138
Hi Bart,
Thanks for your valuable suggestion.I will keep a look at Apache my faces Trinidad.

Muneeswaran Balasubramanian
Ranch Hand

Joined: Mar 19, 2010
Posts: 138
Hi tim,
Thanks for your solution.
I agree. Here's the link:
subject: h:form vs a4j:form
It's not a secret anymore!