JSF - ActionListener的代码调用不带一个ActionEvent参数法 [英] JSF - actionListener tag calls method which doesn't take an ActionEvent parameter
问题描述
我继续读的帖子这不能不说ActionListener的方法必须具有以下signiture:
I keep reading posts which say that ActionListener methods must have the following signiture:
public void calledByActionListener(ActionEvent e) {
}
调用,像这样:
<p:commandButton value="Example" id="example" process="@this" ajax="false"
actionListener="#{exampleBean.calledByActionListener()}">
不过,我有一个无参数的方法,这样其中工程:
However I have a no-arg method like this which works:
public void calledByActionListener() {
}
做了一些改变?
推荐答案
是的,这是新的 EL 2.2调用自定义参数的方法的功能。基本上,你明确地调用一个方法argumentless。这种结构是合法的。
Yes, that's the new EL 2.2 feature of invoking methods with custom arguments. Basically, you're explicitly invoking an argumentless method. This construct is legit.
请注意,这是不相关的JSF2。 EL 2.2恰好是Java EE 6的,以及像JSF2的一部分。因此,它的看起来像的新JSF2功能。但实际上并非如此。作为证据,JSF2与Java EE 5,它意味着这样EL 2.1向后兼容,但这一构造不会在那里工作。
Note that this is not related to JSF2. EL 2.2 just happens to be part of Java EE 6 as well like JSF2. So it look like a new JSF2 feature. But it actually isn't. As evidence, JSF2 is backwards compatible with Java EE 5 which thus implies EL 2.1, but this construct doesn't work over there.
在没有明确指定的方法前pression任何自定义参数,JSF将按照规范在实际的方法假设的ActionEvent
的默认参数。
When not explicitly specifying any custom arguments in the method expression, JSF will as per the specification assume a default argument of ActionEvent
in the actual method.
这篇关于JSF - ActionListener的代码调用不带一个ActionEvent参数法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!