2008-10-22 112 views
3

在下面的Web Flow中,我将表单数据绑定到视图状态下的提交事件的流变量(lifeCycleForm)。我已经验证过,名称,标签和说明属性均按预期填充。如何在Spring Web Flow 2中的视图状态和操作状态之间传递模型数据

但是,当评估操作状态中的表达式时,所有三个属性均为空。我的表单bean是可序列化的,我只是使用简单的字符串属性。

我做错了什么?

我是Spring WebFlow的新手,所以我可能错失了一些明显的东西。

<var name="lifeCycleForm" class="com.btmatthews.freelancer.lifecycle.portlet.LifeCycleForm" /> 

<view-state id="createLifeCycle" model="lifeCycleForm"> 
    <binder> 
     <binding property="name" required="true" /> 
     <binding property="label" required="true" /> 
     <binding property="description" required="false" /> 
    </binder> 
    <transition on="submit" to="createLifeCycleAction" /> 
    <transition on="cancel" to="lifeCycleCreationCancelled" bind="false" /> 
</view-state> 

<action-state id="createLifeCycleAction">   
    <evaluate expression="lifeCycleService.createLifeCycle(lifeCycleForm.name, lifeCycleForm.label, lifeCycleForm.description, null, null)" /> 
    <transition on="success" to="lifeCycleCreated" /> 
    <transition on="failure" to="createLifeCycle" /> 
</action-state> 

<end-state id="lifeCycleCreated" /> 

<end-state id="lifeCycleCreationCancelled" /> 

更新:我忽略了我原来的帖子提到,有人认为是失败的我的单元测试。从那以后,我了解到AbstractFlowExecutionTests没有实现请求参数的绑定。这对我来说似乎有点疏忽了。我已经试过最新的每晚Spring WebFlow 2.0.4,并且行为依然如此。

更新:我的问题是,Spring WebFlow嘲笑不模拟表单提交。

由于提前, 布赖恩

+0

我唯一的建议是将LifeCycleForm作为一个完整的对象(不是一片一片地)传递给lifeCycleService,并通过调试来查看该方法是什么样的......我没有发现任何错误, ,但我只使用Webflow 1.0 :( – MetroidFan2002 2008-10-23 01:32:28

回答

1

要多少懊恼的是,我最近也发现了一个Webflow测试模拟并不使用Spring的结合。您是否曾尝试在像Eclipse这样的IDE内使用像Tomcat这样的容器中的调试来运行流程?如果你没有,这将是非常有用的。如果您需要帮助,我可以提供进一步的提示,但要开始我会说如果您还没有下载Eclipse Web Standard Tools和Web Tools Project插件。如果你真的想能够单元测试绑定,你仍然可以使用Spring Webflow 1 FormActions绑定到模型对象,即使它会使你的流程略微更加冗长。