在下面的 Web Flow 中,我将表单数据绑定到视图状态下提交事件上的流变量 (lifeCycleForm)。我已验证名称、标签和描述属性均按预期填充。
然而,当计算动作状态中的表达式时,所有三个属性都为空。我的表单 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" />
Update:我在最初的帖子中忘记提及是我的单元测试失败了。我后来了解到 AbstractFlowExecutionTests 没有实现请求参数的绑定。这对我来说似乎有点疏忽。我已经尝试过最新的 nightly Spring WebFlow 2.0.4,行为保持不变。
Update:我的问题是 Spring WebFlow 模拟不模拟表单提交。
提前致谢,
布莱恩
令我懊恼的是,我最近还发现 Webflow 测试模拟不使用 Spring 的绑定。您是否尝试过在 Eclipse 等 IDE 中的 Tomcat 等容器中使用调试来运行流程?如果你还没有,它将非常有用。如果您需要帮助,我可以提供更多提示,但首先我建议您下载 Eclipse Web Standard Tools 和 Web Tools Project 插件(如果您还没有下载的话)。
顺便说一句,如果您确实希望能够对绑定进行单元测试,您仍然可以使用 Spring Webflow 1 FormActions 来绑定到模型对象,尽管这会使您的流程稍微更加冗长。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)