Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Execute two methods in action in JSF

Tags:

jsf

jsf-2

Is it possible to execute two methods in action of <h:commandButton>?

For example,

<h:commandButton action="#{bean.methodOne();bean.methodTwo();}" />
like image 637
IAdapter Avatar asked Oct 27 '11 07:10

IAdapter


2 Answers

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.

like image 163
Narendra Yadala Avatar answered Nov 08 '22 02:11

Narendra Yadala


Add a methodThree in your bean :

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

And call this method from the JSF page.

like image 6
JB Nizet Avatar answered Nov 08 '22 04:11

JB Nizet