Search code examples
javajsfjakarta-eerichfacesajax4jsf

AjaxBehaviorEvent vs ActionEvent in JSF2


Recently I've been trying to upgrade this application that I'm working on from JSF 1.2 to JSF 2, and during the process I've hit a wall, as you might already know AjaxBehaviorEvent is all new to JSF, and back in JSF 1.2 and using RichFaces 3 I was able to do the following:

Have a single method's signature in the backing bean

public void onSomeEvent(ActionEvent evt){
    //Process the event
}

and I could call this method in the following two locations as follows 1-

<h:commandButton actionListener="#{bean.onSomeEvent}" value="Process Event"/>

2-

<h:commandButton value="Process Event" >
    <a4j:support event="oncomplete" actionListener="#{bean.onSomeEvent}" />
</h:commandButton>

Now in JSF 2 there's two types of events the old ActionEvent and the new AjaxBehaviorEvent and neither seems to work interchangeably with the other, I mean if I'm to use the method with f:ajax then it needs to have AjaxBehaviorEvent in its arguments list, and if I'm to use it with ordinary DHTML events of the components then it needs to have an ActionEvent in the arguments list.

I was wondering if there's some way to use for instance do what I used to do in JSF 2 with both types of events.

Thank you all.


Solution

  • I did manage to overcome this issue by using EL 2.2 as suggested by @maple_shaft, what I did is that I removed the ActionEvent arguments from the methods where I had had no use of it.