为什么a:commandLink的action属性有效,而h:commandLink的无效? [英] why a:commandLink's action attribute works but h:commandLink's does not?

查看:61
本文介绍了为什么a:commandLink的action属性有效,而h:commandLink的无效?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我今天有一个非常简单的任务,需要帮助.首先让我解释一下我的环境. 我们在Java/Hibernate/SEAM/Facelets/JSF/RichFaces& A4J设置..我对此不太了解.

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.

当旧的asp平台上的所有工作都完成时,我会使用它.

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

所以我有这样的事情(我只是不记得在stockCheck之后是否有().我现在在家):

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()"/>

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.

因此,我尝试了一些尝试,但没有任何效果,我问了我的同事,他说只需将其更改为a4j即可.我问他为什么,但他不知道.

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()"/>

顺便说一句:我们将a4j的命名空间设置为a.

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

我在这里希望有人可以向我解释一些事情.

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

在这种情况下,幕后发生了什么以及<h:commandLink>的失败需要了解什么?

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

谢谢.

推荐答案

如果您嵌套表格,则可能会发生这种情况.这在HTML中是非法的,并且行为是不确定的,并且取决于所使用的Web浏览器. Ajax链接不提交表单,它只是通过JavaScript收集输入值,然后在后台发送XMLHttpRequest.

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.

这篇关于为什么a:commandLink的action属性有效,而h:commandLink的无效?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆