【问题标题】:Why isn't webflow updating my model object?为什么 webflow 不更新我的模型对象?
【发布时间】:2012-05-08 16:32:40
【问题描述】:

我正在使用 Spring Webflow 2 设置应用程序,但遇到了问题。该应用程序在一个页面上进行预订,然后允许在另一个页面上付款。预留模型对象工作正常;我可以填写表格并提交它,它会在以下确认屏幕上显示完全填充的对象。然而,当我对 paymentInformation 模型对象做同样的事情时,表单的任何内容在处理时都不会绑定到模型对象中。

这是我的流程定义。 (在尝试解决此问题时,我将支付流程移到了子流程中。)

<?xml version="1.0" encoding="UTF-8"?>
<flow 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://www.springframework.org/schema/webflow"
    xsi:schemaLocation="http://www.springframework.org/schema/webflow http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd">

    <var name="paymentInfo" class="com.myapp.payments.domain.PaymentInfo" />
    <input name="reservation" />

    <decision-state id="paymentDecision">
        <if test="reservationServiceImpl.needsPayment(reservation)" 
            then="enterPayment"
            else="resolvePayment" />
    </decision-state>

    <view-state id="enterPayment" view="enterPayment" model="paymentInfo">
        <on-render>
            <evaluate expression="reservationMultiAction.preparePayment" />
            <set name="viewScope.stepNumber" value="3" />
        </on-render>

        <transition on="back" to="editReservation" />
        <transition on="submitPayment" to="resolvePayment" />
    </view-state>

    <action-state id="resolvePayment">
        <evaluate expression="reservationMultiAction.submitPayment" />
        <transition on="success" to="receipt" />
        <transition on="failure" to="payment" />
    </action-state>

    <end-state id="editReservation" />
    <end-state id="receipt" />
</flow>

调用preparePayment 填充flowScope 中的bean,然后正确填充enterPayment 页面上的表单。但是当我调试 submitPayment 操作方法时,paymentInfo bean 只有 preparePayment 的结果,而提交的表单中什么都没有。

我相信有人会问,这里是 enterPayment 页面的开始表单标签:

<form:form modelAttribute="paymentInfo" method="post">

【问题讨论】:

    标签: java spring-webflow spring-webflow-2


    【解决方案1】:

    如果不包含完整的 html 代码,则很难识别错误。乍一看,它可能是表单标签中缺少的操作属性。

    <form:form action="${flowExecutionUrl}" modelAttribute="paymentInfo" method="post">
        <input type="submit" id="_eventId" value="submitPayment" />
    </form:form>
    

    【讨论】:

    • 它并没有错过动作,因为它是自我发布回到流程中,但你让我找到了正确的位置。我们使用不使用提交输入类型的自定义按钮,并且我将它与流程中未提交表单的其他按钮混合在一起。我的按钮只是链接到下一个视图状态而不是提交表单,这就是它移动到正确位置但行为错误的原因。轻松解决此类烦人的问题。
    猜你喜欢
    • 2015-06-09
    • 1970-01-01
    • 2015-07-25
    • 1970-01-01
    • 1970-01-01
    • 2014-06-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多