aspose file tools*
The moose likes JSF and the fly likes Why does exist the possibility to create a custom actionListener? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Why does exist the possibility to create a custom actionListener?" Watch "Why does exist the possibility to create a custom actionListener?" New topic
Author

Why does exist the possibility to create a custom actionListener?

massimo tarantelli
Ranch Hand

Joined: Jun 19, 2012
Posts: 35

Hello to everybody, i know that i can use both:


and


But i don't understand the need of the second one, infact in both I can write what i want inside the method.
I mean, what is customizable in the second one that is not possible in the first one?
thanks
Massimo
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16068
    
  21

JSF was really confusing while it was being designed originally, and I think that action methods might not have existed then, because an awful lot of people use listeners when they shouldn't and the only reasons I can come up with is because they either were using out-of-date documentation or they wanted a complicated solution to a simple problem.

ActionListeners are something I almost never use, because they require JSF-aware code and usually don't do anything that a POJO action method cannot do without the need to tie the code to JSF or to the JSF runtime (which means it's a lot easier to run offline testing).

However, there are exceptions. A downside of action methods is that for a given command control, there can be only one action method. However, you can jam as many action listeners on that control as you want to. They will, of course, all need to be JSF-aware, but in some cases that's simpler than the alternative, which would be to aim the control at a master action method whose job was to invoke multiple secondary action methods.


Customer surveys are for companies who didn't pay proper attention to begin with.
massimo tarantelli
Ranch Hand

Joined: Jun 19, 2012
Posts: 35

thanks for the aswer.
 
 
subject: Why does exist the possibility to create a custom actionListener?