0

I'm setting up an application using Spring Webflow 2, and I'm running into a problem. The app takes in a reservation on one page and then allows for payment on another page. The reservation model object works fine; I can fill out the form, submit it, and it shows the fully populated object on the following confirmation screen. When I do the same thing with the paymentInformation model object however, none of the form's contents are bound into the model object when it is processed.

Here's my flow definition. (I moved the payment flow into a subflow while I was trying to troubleshoot this problem.)

<?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>

Calling preparePayment populates the bean in the flowScope, and then correctly populates the form on the enterPayment page. But when I debug the submitPayment action method, the paymentInfo bean only has the results of preparePayment, and nothing from the submitted form.

And since I'm sure someone will ask, here's the opening form tag from the enterPayment page:

<form:form modelAttribute="paymentInfo" method="post">
Travelsized
  • 111
  • 3
  • 11

1 Answers1

0

It is hard to identify the error if full form html code is not included. At first sight, it could be a missing action attribute in the form tag.

<form:form action="${flowExecutionUrl}" modelAttribute="paymentInfo" method="post">
    <input type="submit" id="_eventId" value="submitPayment" />
</form:form>
txedo
  • 956
  • 11
  • 11
  • It wasn't missing the action since it was self-posting back to the flow, but you made me look in the right spot. We use custom buttons that don't use the submit input type, and I had mixed it up with other buttons in the flow that weren't submitting forms. I had the button just linking to the next view-state instead of submitting the form, which is why it was moving to the right place but behaving wrong. Easy fix for such an annoying problem. – Travelsized May 08 '12 at 14:20