1
votes

Just getting the hang of Spring Webflow. I have some simple forms working and binding back and forth - very cool. One thing not obvious to me at the moment is how to dynamically launch a flow based on user input.

i.e. imagine a flow where the user chooses an option in the first screen, and based on the choice taken, different subflows can be initiated. In pseudo-terms something like the following pseudo-flow:

    <view-state id="selectService" model="serviceType">
            <transition on="proceed">
               <if "serviceType.selectedValue==1" to="subFlow1" />
               <if "serviceType.selectedValue==2" to="subFlow2" />
               <if "serviceType.selectedValue==3">
                      <if "serviceType.isValid==3" to="subFlow3" />
               </if>
               <default to="cancel" />
             </transition>
            <transition on="cancel" to="cancel" />
    </view-state>

I've trawled the examples, docs, stackoverflow and the spring forums but haven't seen this anywhere..

2

2 Answers

1
votes

It is covered in Spring in Action 3, which is a great book for Spring development in my eyes.

To answer your question here though, I think you are looking for the decision-state transition element. To get to user input, you should be able to use Spring Expression Language (SpEL) in the test attribute.

1
votes

I tried using the decider recently, but frankly, for any non-trivial logic, it's best to move it to a Java method where you can easily unit test it. Then call said method and use the output from there. It's best to keep the flow XML files as simple as you can.