在JSF中依次执行两个动作侦听器

Executing two action listeners one after another in JSF

在我的 ADF 项目的一个 jsff 文件中,我有一个用于搜索页面上显示的一些信息的按钮。

<af:button actionListener="#{bindings.ExecuteWithParams.execute}"
            text="SEARCH"
            id="button"/>

之后我有一个按钮可以编辑显示的信息。

<af:commandMenuItem text="edit"
           actionListener="#{viewScope.bean.editPopup}"
           id="editBtn" immediate="true">

这里的主要思想是当 actionListener="#{viewScope.bean.editPopup}" 执行时,然后自动执行 actionListener="#{bindings.ExecuteWithParams.execute}"

你有什么想法可以实现吗?谢谢!

您可以捕获辅助 bean 中的单个按钮单击并从那里调用这两种方法。这个blog should help. Also this.

对于 viewScope bean,helper Static classes that you can use to get a reference to the bean into your backing bean and then call the viewScope bean method there. Look at JSFUtils.java. This blog 较旧,但也可能有帮助。

在这种情况下,您可以在 ActionListener (editPopup) 中以编程方式调用 executeWithParams 只需在您的 pageDef 中添加操作并使用 OperationBinding

调用
BindingContainer bindings = BindingContext.getCurrent().getCurrentBindingsEntry(); 
OperationBinding method = bindings.getOperationBinding("methodAction");  
Object result = method.execute();