The order of Action and ActionListener in JSF

Hi, I always bump into this question when doing consultancies on clients about actions and action listeners and the order they are called.

Let’s assume that we have a p:commandButton which has an action, an actionlistener, some setPropertyActionListeners and a f:actionListener. The code will be something like:

<p:commandButton actionListener="#{actionListenerBean.actionListener}" action="#{actionListenerBean.action}" value="click me">
        <f:setPropertyActionListener target="#{}" value="some value"/>
        <f:actionListener type="" />
        <f:setPropertyActionListener target="#{actionListenerBean.property2}" value="some other value"/>

and our Java code is as follows ( a bit crappy for demo ) :

@ManagedBean(name = "actionListenerBean")
public class ActionListenerBean implements ActionListener {

	public void actionListener(ActionEvent actionEvent){
		System.out.println("actionListener of the button is called");
	public String action(){
		System.out.println("action of the button is called");
		return null;

	public void setProperty(String property) {
		System.out.println("f:setPropertyActionListener for property is called");

	public void setProperty2(String property2) {
		System.out.println("f:setPropertyActionListener for property2 is called");
	public void processAction(ActionEvent ae) throws AbortProcessingException {
		System.out.println("f:actionlistener is called");

when we click on the button, the output is as follows:

actionListener of the button is called
f:setPropertyActionListener for property is called
f:actionlistener is called
f:setPropertyActionListener for property2 is called
action of the button is called

As you can see first the actionListener of the button is called, then the actionListeners that are inside the button are called in the order they are added to the button and finally action of the button is called.

If you are trying to set some data with f:setPropertyActionListener but cannot see it in your actionListener method of your button, the order of the actionListeners is the reason.