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"





About Krishna Srinivasan

He is Founder and Chief Editor of JavaBeat. He has more than 8+ years of experience on developing Web applications. He writes about Spring, DOJO, JSF, Hibernate and many other emerging technologies in this blog.

Speak Your Mind


Please support the site
By clicking any of these buttons you help our site to get better