Today in this article we will learn difference between action and action listener in JSF. JSF is a component rich framework. You get lot of features in JSF.
While working on any business requirement, you will get all kind of component to in JSF. Components in JSF are rich in design and functionality also.
JSF has lot of special features to track user action. For example Value Change Listener, Action Listener, Action etc.
In this article we will see the differences between Action and Action Listener.
Understand Action and Action Listener
Let us understand Action and Action Listener for time being. Action is directly something when user submits a form or click on a action button.
On the other hand Action Listener is for tracking users action. Let us understand both with examples.
What is Action in JSF ?
Action is a related to form submission. Once you click on action you will perform a business logic in managed bean. Moreover you can navigate to another page or can return back on the same page.
To summarise action logic will be handled inside the managed bean. You can write logic inside the managed bean and handle the page navigation also.
As it is always better to learn the code and concepts with example. Once you have completed this example, you will get better idea of Action in JSF. Please drop a message in case you face any issue while doing that example.
What is Action Listener ?
On the other hand Action Listener also perform some business logic. But the major difference is it does not navigate to next page.
So to handle navigation you need Action. On the other hand to track user action you need Action Listener.
While user action you have ActionEvent class in JSF. You can use methods of this class to get track of user activities.
Here we have a list of JSF tutorial. Please visit to learn.
Finally, you have got an understanding of Action and ActionListener. Please feel free to drop comment if you have any points on this topic.
So Action and Action Listener are complement to each other. Both perform certain actions related to business. But Action has extra addition to facilitate page navigation.
While Action Listener return the same page after performing certain on page logics. For example updating list of objects, session values etc.