在JSF中执行两个实际操作方法

IAd*_*ter 23 jsf jsf-2

是否可以执行两种方法<h:commandButton>

例如,

<h:commandButton action="#{bean.methodOne();bean.methodTwo();}" />
Run Code Online (Sandbox Code Playgroud)

Nar*_*ala 46

你可以f:actionListener像这样使用.

  <h:commandButton action="#{bean.methodOne();}">
    <f:actionListener binding="#{bean.methodTwo();}" />
  </h:commandButton>
Run Code Online (Sandbox Code Playgroud)

您可以f:actionListener根据需要添加任意数量的元素.

  • 这些动作是否按顺序执行? (2认同)

JB *_*zet 7

在bean中添加一个methodThree:

public Object methodThree() {
    methodOne();
    methodTwo();
    return someThing;
}
Run Code Online (Sandbox Code Playgroud)

并从JSF页面调用此方法.

  • 我知道我可以做到这一点,但我不能调用两种方法? (2认同)