JSF Command button call two methods?

Buttons are used to perform some actions by submitting the form or through Ajax calls. In some scenarios we may need to perform two different actions in on button click. But action attribute allows to specify only one method to back end bean. So how can we achieve this behavior. Please see the code snippet below. In below code snippet on click of button both the methods A & B get called in the back end bean. We can write multiple methods calls like this.

<h:commandButton id="twomethod" value ="TwoMethodCall" action="#{bean.methodA()}">
    <f:actionListener binding="#{bean.methodB()}" />


Post a Comment

Powered by Blogger.