Take the 2-minute tour ×

Is there a way to call multiple methods from different backing beans in JSF?

I have an application that stores user information. I have multiple backing beans which are broken down into schedule, address, phone.. etc.

When the application initially loads everything works find but since all of my views are of type @ViewScope the lists of schedule, address, phone are maintained even if a new user is displayed.

I need to manually set the schedule, address, and phone lists to null when the user navigates away from the current person they are viewing IE I need to call a method in each managed bean at one point in time (When the user clicks on a commandLink).

Is it possible to call multiple bean methods on one commandLink?

share|improve this question

2 Answers 2

<h:commandLink action="#{jsfBean.submit}" value="execute multiple methods">
    <f:actionListener binding="#{jsfBean1.actionListener}"/>
    <f:actionListener binding="#{jsfBean2.actionListener}"/>
    <f:actionListener binding="#{jsfBean3.actionListener}"/>

Using the above code,

when you click the commandLink first the submit method will be executed. After that all the other actionListeners will be executed one by one...Hope that helps ;)

share|improve this answer
That was helpful! :) –  Nikhil Patil Apr 5 '11 at 15:31
@Nikhil glad to hear that :) –  Selvin Apr 7 '11 at 5:29
"Note that the JSF implementation always invokes action listeners before actions." - Core JavaServer Faces (3rd ed.), page 314. –  Steve Taylor Jan 3 '12 at 17:18

You can have your commandLink reference one method which itself calls all the necessary methods.

share|improve this answer

Your Answer


