I\'m using Glassfish 3.1.2.2 and JSF Mojarra 2.1.6.
I have the following Facelets page:
<
This is the consequence of the new EL 2.2 feature of calling a method in a value expression via the #{bean.method()}
syntax instead of only referencing a property via the #{bean.property}
syntax (which should indeed be of the exact type ActionListener
). It wouldn't have worked in EL 2.1 or older and it would also not work when you remove the arguments and the parentheses. That document was written when EL 2.2 didn't exist (it's actually not modified as compared to JSF 1.2 version from May 2006; EL 2.2 was introduced December 2009). I however do agree that it needs an update on that part as it's confusing to starters.
The answer you found made its points based on the document, but the answerer however didn't seem to realize based on the question that while binding="#{testController.nodeListener}"
failed, the binding="#{testController.nodeListener(event)}"
actually worked. This only doesn't give you the opportunity to pass the ActionEvent
. The answer was better if it suggested to just use binding="#{testController.nodeListener()}"
instead and grab the event information in other way, such as by calling UIComponent#getCurrentComponent() or even by passing #{component}
as argument. Only if you really need to have a hand of it, of course.
public void someMethod(UIComponent component) {
System.out.println("It was called on: " + component); // HtmlCommandLink
}