简体   繁体   English

为什么a:commandLink的action属性有效,而h:commandLink的无效?

[英]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. 我们在Java / Hibernate / SEAM / Facelets / JSF / RichFaces和A4J设置中..我对此并不了解。

I work with it when all of the work on the old asp platform is complete. 当旧的ASP平台上的所有工作完成时,我将使用它。

SO I had something like this (I just cannot remember if I had () after stockCheck.. I am home now): 所以我有这样的事情(我只是不记得在StockCheck之后是否有()。我现在在家):

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

The stockCheck() method would NOT run though! stockCheck()方法不会运行! 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. 因此,我尝试了几件事,但没有任何效果,我问了我的同事,他说只要将其更改为a4j即可。 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. 顺便说一句:我们将a4j的命名空间设置为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? 在这种情况下,幕后发生了什么以及<h:commandLink>的失败需要了解什么?

Thank you. 谢谢。

That can happen if you're nesting forms. 如果您要嵌套表格,则可能会发生这种情况。 This is illegal in HTML and the behaviour is unspecified and dependent on the webbrowser used. 这在HTML中是非法的,并且行为未指定且取决于所使用的Web浏览器。 The ajax link doesn't submit the form, it just collects the input values by JavaScript and then sends a XMLHttpRequest in the background. ajax链接不提交表单,它只是通过JavaScript收集输入值,然后在后台发送XMLHttpRequest

See also: 也可以看看:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM