Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Different between action and actionListener  RSS feed

 
Sloan Bowman
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When creating Beans with action or action listener methods can somebody help me determine which to use in what situation. To be they both seem closely related other than the actionListener does not handle navigation. Can someone give me some examples on their proper use.
 
Varun Khanna
Ranch Hand
Posts: 1400
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ActionListener can be called in any phase of the life cycle whereas action are fired at a fixed phase e.g. if you want to execute some business process prior to Validation phase, you will go for an actionListener.
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To add to what Varun said, action is typically used to perform navigation whereas actionListeners typically perform some same page logic and then the page just posts back to itself.
 
Sloan Bowman
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I appreciate the help guys it helped me understand much better. I'm slowly but surely starting to get a grasp on JSF.
 
Mauro Castaldo
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Varun Khanna:
ActionListener can be called in any phase of the life cycle whereas action are fired at a fixed phase e.g. if you want to execute some business process prior to Validation phase, you will go for an actionListener.

Sorry but it's not correct.
ActionListener and actions have the same behavior related to lifecycle phases; they will be executed at the end of the Apply Request phase if immediate="true" or at the end of the Invoke Application phase if immedaite="false".
The main differences are:
- you should use actions if you need to navigate (if success) but you don't need to manage interface (you access mainly bounded values).
- you should use ActionListeners if you need to access, aupdate or modify interface but you don't need to navigate; you can access the component that triggered the ActionListener through ActionEvent parameter.
- you can have only one action but multiple ActionListeners.

Mauro
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!