Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 388
Sabry Shawally Avatar asked Feb 01 '26 15:02

Sabry Shawally


1 Answers

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.

like image 55
Sabry Shawally Avatar answered Feb 04 '26 04:02

Sabry Shawally



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!