在下面的Web Flow中,我将表单数据绑定到视图状态中的提交事件的流变量(lifeCycleForm)。我已经验证了名称,标签和描述属性都按预期填充。

但是,当评估动作状态中的表达式时,所有三个属性都为null。我的表单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模拟不会模拟表单提交。

提前致谢, 布赖恩

有帮助吗?

解决方案

令人懊恼的是,我最近还发现Webflow测试模拟不使用Spring的绑定。您是否尝试过使用像Tomcat这样的容器中的调试来运行流程?如果你没有,那将非常有用。如果您需要帮助,我可以提供进一步的提示,但是首先我要说下载Eclipse Web标准工具和Web工具项目插件(如果您还没有。)

正如旁注,如果您真的希望能够进行单元测试绑定,您仍然可以使用Spring Webflow 1 FormActions绑定到模型对象,即使它会使您的流程稍微冗长。 / p>

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top