0
votes

TL;DR - Is there a way in the model binding within Spring Web Flow to map HTTP Request Parameters to the model property?

The Problem:

My Spring Web Flow application is accessed through a 3rd party product. Our clients connect to the external product, do some things, and then requests from the 3rd party product are sent into our web flow. We then send responses back which tell the external platfrom what to do next.

Because of this, I do not have control over the HTTP request parameters that are being sent, however I still am trying to leverage Spring Web Flow binding.

Model Object

public class MyModel {
    private String _value;
    public void setValue(String value);
    public String getValue();
}

Flow Snippet

<?xml version="1.0" encoding="utf-8"?>
<flow>
    <on-entry>
        <evaluate expression="new MyModel()" result="flowScope.myModel" />
    </on-entry>
    <view-state id="myForm" model="myModel">
        <binder>
            <binding property="value" converter="my_converter" required="true" />
        </binder>
        <transition on="submit" to="confirm" />
    </view>
</flow>

However, when the actual HTTP request is passed in for submission, the request parameters look like:

http://web-foo/my-flow?execution=e1s1&_eventId_submit=Submit&Content=ClientValue

Is there any way, outside of using custom actions etc to tell the binder that I want it to grab the value of the HTTP Request Parameter Content and set it on the value property on my Model Object. Future requests will re-use the same HTTP parameter, so I can't just update my model because the value will keep getting overwritten

1

1 Answers

1
votes

create an input in your flow:

<input name="Content" type="string"/>

it will be filled with the request parameter automatically.

then simply set it on your model:

<on-entry>
    <evaluate expression="new MyModel()" result="flowScope.myModel" />
    <set name="myModel.value" value="Content"/>
</on-entry>

...