Call multiple backing bean methods at the same time

后端 未结 3 1880
暖寄归人
暖寄归人 2021-02-02 12:58

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

相关标签:
3条回答
  • 2021-02-02 13:01

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

    0 讨论(0)
  • 2021-02-02 13:06
    <h:commandLink action="#{jsfBean.submit}" value="execute multiple methods">
        <f:actionListener binding="#{jsfBean1.actionListener}"/>
        <f:actionListener binding="#{jsfBean2.actionListener}"/>
        <f:actionListener binding="#{jsfBean3.actionListener}"/>
    </h:commandLink>
    

    Using the above code, with methods in the beans have the ('default') signature of actionListener(ActionEvent event)

    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 ;)

    0 讨论(0)
  • 2021-02-02 13:21

    The answers here were close to working for me but also had to add parenthesis to the methods in the f:actionListener:

    <h:commandLink action="#{jsfBean.submit}" value="execute multiple methods">
        <f:actionListener binding="#{jsfBean1.actionListener()}"/>
        <f:actionListener binding="#{jsfBean2.actionListener()}"/>
        <f:actionListener binding="#{jsfBean3.actionListener()}"/>
    </h:commandLink>
    
    0 讨论(0)
提交回复
热议问题