Execute two methods in action in JSF

You can use f:actionListener like this.

  <h:commandButton action="#{bean.methodOne()}">
    <f:actionListener binding="#{bean.methodTwo()}" />
  </h:commandButton>

You can add as many f:actionListener elements as you need.


Add a methodThree in your bean :

public Object methodThree() {
    methodOne();
    methodTwo();
    return someThing;
}

And call this method from the JSF page.


The accepted answer was close to working for me but the semi-colon was throwing a parse exception. The below code worked:

<h:commandButton>
    <f:actionListener binding="#{bean.methodTwo()}" />
</h:commandButton>

Tags:

Jsf

Jsf 2