在JSF中执行两个实际的方法

在JSF中执行两个实际的方法,jsf,jsf-2,Jsf,Jsf 2,是否可以在的操作中执行两种方法 比如说, <h:commandButton action="#{bean.methodOne();bean.methodTwo();}" /> 在bean中添加方法三: public Object methodThree() { methodOne(); methodTwo(); return someThing; } 并从JSF页面调用此方法。您可以这样使用 <h:commandButton action="#{

是否可以在
的操作中执行两种方法

比如说,

<h:commandButton action="#{bean.methodOne();bean.methodTwo();}" />

在bean中添加方法三:

public Object methodThree() {
    methodOne();
    methodTwo();
    return someThing;
}
并从JSF页面调用此方法。

您可以这样使用

  <h:commandButton action="#{bean.methodOne()}">
    <f:actionListener binding="#{bean.methodTwo()}" />
  </h:commandButton>


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

接受的答案对我来说很有用,但分号抛出了一个解析异常。以下代码有效:

<h:commandButton>
    <f:actionListener binding="#{bean.methodTwo()}" />
</h:commandButton>


我知道我可以做到这一点,但我无法从Mojara javadoc中调用两个方法,用于
h:commandButton
action
属性:MethodExpression,表示用户激活此组件时要调用的应用程序操作。表达式必须计算为不带参数的公共方法,并返回一个对象(调用该对象的toString()以派生逻辑结果),该对象将传递给此应用程序的NavigationHandler。谢谢。我编辑了我的答案以反映一个事实,即必须返回一个对象。void当前也被允许。这些操作是否按顺序执行?您在这里只调用一个方法!