How to implement ActionListener (f:actionListener) in JSF?


This article explains how to implement the ActionListener class in the JSF core tag library.

also read:

An ActionListener is an event handler interface for a class that can respond to user events in your JSF page. The body content of this tag must be empty.

JSP File (index.jsp)

<%@taglib prefix="f" uri=""%>
<%@taglib prefix="h" uri=""%>
               <h:inputText value="#{jsfBean.field}"/>
               <h:commandButton action="#{jsfBean.submit}" value="Submit">
                    <f:actionListener binding="#{jsfBean.actionListenerImpl}" type="javabeat.jsf.ActionListenerImpl"/>

JavaBean (

package javabeat.jsf;

import javax.faces.event.ActionEvent;

 * source :
public class JavaBeatJsfBean {

    private String field;
    private ActionListenerImpl actionListenerImpl;

    public ActionListenerImpl getActionListenerImpl() {
        return actionListenerImpl;

    public void setActionListenerImpl(ActionListenerImpl actionListenerImpl) {
        this.actionListenerImpl = actionListenerImpl;
    public String getField() {
        return field;

    public void setField(String field) {
        this.field = field;
    public void action() {
        System.out.println("Inside Action Listener");

    public void action(ActionEvent event) {
        System.out.println("Inside Action Listener");

    public String submit() {
        return "success";

ActionListener implementation class (

package javabeat.jsf;

import javax.faces.event.AbortProcessingException;
import javax.faces.event.ActionEvent;
import javax.faces.event.ActionListener;

public class ActionListenerImpl implements ActionListener {

    public void processAction(ActionEvent event)
            throws AbortProcessingException {
        System.out.println("Inside Process Action");


<?xml version='1.0' encoding='UTF-8'?>

<faces-config version="1.2"



Leave a Reply

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

Pin It on Pinterest

Share This

Share this post with your friends!