JoJo
JoJo

Reputation: 4923

why a:commandLink's action attribute works but h:commandLink's does not?

I had a very simple task today that I needed help with. First let me explain my environment. We are on a Java/Hibernate/SEAM/Facelets/JSF/RichFaces & A4J setup.. and I don't know to much about it.

I work with it when all of the work on the old asp platform is complete.

SO I had something like this (I just cannot remember if I had () after stockCheck.. I am home now):

<h:commandLink value="Submit" action="session.stockCheck()"/>

The stockCheck() method would NOT run though! It does not return a value it's job is to create a record in a DB, and it does that perfectly.

So I tried a few things and nothing would work, I asked my co-worker and he said to just change it to a4j and it should work. I asked him why, but he did not know.

See now I get REALLY hung up when I do not understand WHY things are or are not working.

The solution to submit the email to the database was:

<a:commandLink value="Submit" action="session.stockCheck()"/>

BTW: we have our namespace for a4j set to just a.

I am here hoping somebody can explain some things about this to me.

What went on behind the scenes and what needs to be understood about the failure of <h:commandLink> in this situation?

Thank you.

Upvotes: 2

Views: 1315

Answers (1)

BalusC
BalusC

Reputation: 1108642

That can happen if you're nesting forms. This is illegal in HTML and the behaviour is unspecified and dependent on the webbrowser used. The ajax link doesn't submit the form, it just collects the input values by JavaScript and then sends a XMLHttpRequest in the background.

See also:

Upvotes: 1

Related Questions