3
votes

In the Web Flow below I bind form data to a flow variable (lifeCycleForm) on a submit event in the view state. I have verified that the name, label and description properties are all populated as expected.

However, when the expression in the action state is evaluated all three properties are null. My form bean is serializable and I am just using simple string properties.

What I am doing wrong?

I am pretty new to Spring WebFlow so I might have missed something obvious.

<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: I neglected to mention in my original posting that it was my unit tests that were failing. I have since learned that AbstractFlowExecutionTests does not implement binding of request parameters. This seems like a bit of an oversight to me. I have tried latest nightly Spring WebFlow 2.0.4 and the behaviour remains the same.

Update: My problems are that Spring WebFlow mocks do not simulate form submission.

Thanks in advance, Brian

1
My only suggestion would be to pass the LifeCycleForm into the lifeCycleService as a complete object (not piece by piece) and see what it is like in that method via debugging...I don't see anything wrong offhand with your flow, but I've only used Webflow 1.0 :(MetroidFan2002
Unfortunately I that I have already tried that and get the same results. Thanks for the suggestion.Brian Matthews
Try placing debugging breakpoints on the setters, then, and see if/where they're hit...MetroidFan2002

1 Answers

1
votes

To much chagrin, I also recently found out that the Webflow testing mocks don't use Spring's binding. Have you tried running the flow using debugging in a container like Tomcat from within an IDE like Eclipse ? If you haven't, it'll be very useful. If you need help, I can provide further tips, but to start I'd say download the Eclipse Web Standard Tools and Web Tools Project plugins if you haven't already.

Just as a side note, if you really want to be able to unit test binding, you can also still use the Spring Webflow 1 FormActions to bind to the model object, even though it will make your flow slightly more verbose.