Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/jsf/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java SpringWebFlow:调用bean';s方法作为目标动作_Java_Jsf_Spring Webflow - Fatal编程技术网

Java SpringWebFlow:调用bean';s方法作为目标动作

Java SpringWebFlow:调用bean';s方法作为目标动作,java,jsf,spring-webflow,Java,Jsf,Spring Webflow,我有一个JSF+springwebflow应用程序,我想使用视图bean中定义的方法从一个视图移动到另一个视图 因此,my flow.xml如下所示: <flow ...> <var name="myBean" class="mypackage.myclass" /> <view-state id="list"> <transition on="myEvent" to="#{myBean.onMyEvent()}"

我有一个
JSF
+
springwebflow
应用程序,我想使用视图bean中定义的方法从一个视图移动到另一个视图

因此,my flow.xml如下所示:

<flow ...>
     <var name="myBean" class="mypackage.myclass" />
     <view-state id="list">
         <transition on="myEvent" to="#{myBean.onMyEvent()}"
     </view-state>
</flow>
按钮简单如下:

<h:commandButton id="myButton" action="myEvent" ajax="false" value="myButton" />

当我按下包含
action=“myEvent”
的按钮时,我得到错误:

EL1004E:方法调用:在类型[…]上找不到onMyEvent()方法

那么,我的代码怎么了?如何在某个事件上调用bean中的方法


谢谢。

最后,我使用可以手动处理事件的解决方案,如以下示例所示:

前端端(调用bean的方法):

最后在
flow.xml
中(管理到下一个视图的转换)



查看错误中的方法签名和代码中的方法签名。注意到一个区别吗?@Kukeltje是的,但操作应该是
flow.xml
中指定的操作。所以我相信这是对的,不是吗?不知道,我不使用像这样复杂的设置。JSF有自己的“流”,不需要像这样相对复杂的解决方案。但你的解决方案正是我的意思。
<h:commandButton id="myButton" action="myEvent" ajax="false" value="myButton" />
<h:ajax event="rowSelect" listener="#{myBean.onMyEvent}" />
public void onMyEvent(final SelectEvent event) {
    // Fill the bean for next view
    final RequestContext requestContext = RequestContextHolder.getRequestContext();
    requestContext.getFlowScope().put("nextBean", nextBean);
    final RequestControlContext rec = (RequestControlContext) requestContext;
    rec.handleEvent(new Event(this, "myEvent")); // the action managed by Spring Web Flow
}
<view-state id="myView">
    <transition on="myEvent" to="nextView" />
</view-state>