Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Why does exist the possibility to create a custom actionListener?

 
massimo tarantelli
Ranch Hand
Posts: 35
Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 18162
53
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
massimo tarantelli
Ranch Hand
Posts: 35
Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for the aswer.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic