Developing Web 2.0 applications
with JavaServerFaces
and Dreamweaver
>> Just Became Easier
Documentation
Search
  1. Introduction
  2. Getting Started
  3. Developing Web Sites
  4. Using Components
  5. Internationalization
  6. Code View Support
  7. Design View Support
  8. Keyboard Shortcuts
  9. Tag Object Toolbars
  10. JSF Server Behaviors
  11. Property Inspectors
  12. JSF Tag Reference
JSF Core Tag Library
Selected f:actionListener
  f:ajax
  f:attribute
  f:convertDateTime
  f:convertNumber
  f:converter
  f:event
  f:facet
  f:loadBundle
  f:metadata
  f:param
  f:phaseListener
  f:selectItem
  f:selectItems
  f:setPropertyActionListener
  f:subview
  f:validateBean
  f:validateDoubleRange
  f:validateLength
  f:validateLongRange
  f:validateRegex
  f:validateRequired
  f:validator
  f:valueChangeListener
  f:verbatim
  f:view
  f:viewParam
If you like this documentation, please take a look at my book:

12. JSF Core Tag Reference

Documentation > JSF > JSF Tag Reference > JSF Core Tag Library > f:actionListener

f:actionListener

The ActionListener tag registers a javax.faces.event.ActionListener instance with the component. An ActionListener is an event handler interface for a class that can respond to user events in your JSF page.

When the button is clicked, JSF will invoke a method named "processAction" on the associated ActionListener object. The body content of this tag must be empty.

Note: it is more common to implement an action listener using the "action" or "actionListener" attributes of a command component, such as h:commandButton or h:commandLink. The f:actionListener tag is useful for cases where you want to implement or reuse common action listener functionality across multiple components.

JSF Example

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" 
      xmlns:f="http://java.sun.com/jsf/core" 
      xmlns:h="http://java.sun.com/jsf/html">
<h:head />
<body>
<h:form>
	<h:commandButton value="Click">
		<f:actionListener type="com.mycompany.MyActionListener" />
	</h:commandButton>
</h:form>
</body>
</html>
This example was formatted by JSFToolbox for Dreamweaver.

Java Code

package com.mycompany;

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

public class MyActionListener implements ActionListener {

	@Override
	public void processAction(ActionEvent event) throws AbortProcessingException {
		System.out.println("ActionListener was called");
	}

}

Rendered Output

Rendered f:actionListener tag

Tag Attributes

binding Expression
 
The value-binding expression linking this component tag to a backing bean property.
for Text
Since JSF 2.0
If present, this attribute refers to the value of one of the exposed attached objects within the composite component inside of which this tag is nested.
type Text
 
The fully qualified Java class name of an ActionListener to be created and registered with the parent component.