Difference between Action and Action Listener in JSF

Like Tweet Pin it Share Share Email

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.

Read this example to learn more about navigations and action tag in JSF.

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.

Conclusion :

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.

Comments (2)

  • if i want to download a file from the command link . what should i use action & actionListener.

    • You can use anyone Action or Action Listener. I will suggest to use ActionListener.

      When you use action in the last you have to return null so that it will load the same page after downloading the file.

      public void downloadFile (){
      //download code
      return null;

      In case of ActionListener you no need to write return statement in the last.

      public void downloadFile (ActionListener event){
      //download code


Leave a Reply

Your email address will not be published. Required fields are marked *