In my project I am using f:ajax listener with arguments like this:
<h:inputText value="#{myBean.person.name}">
<f:ajax
event="change"
listener="#{myBean.doSomething(myBean.person.id)}" />
</h:inputText>
with a listener in MyBean
public void doSomething(Integer id)
{
// do something with id ...
}
The Oracle Documentation f:ajax says that the signature of the listener for f:ajax must match the following:
public void processAjaxBehavior(javax.faces.event.AjaxBehaviorEvent event) throws javax.faces.event.AbortProcessingException)
So according to the Oracle Documentation it should be done like this:
<h:inputText value="#{myBean.person.name}">
<f:attribute
name="identifier"
value="#{myBean.id}"/>
<f:ajax
event="change"
listener="#{myBean.doSomething}" />
</h:inputText>
with a listener in MyBean
public void doSomething(AjaxBehaviorEvent event) throws AbortProcessingException
{
Integer id = (Integer) event.getComponent().getAttributes().get("identifier");
// do something with id ...
}
Both examples work in my application. But the first example is very intuitive and more easy to use.
Are there arguments against using the listener with parameters other than AjaxBehaviorEvent?