Search code examples
springspring-webflowspring-webflow-2

Resuming spring webflow from action state


Is there an option in spring webflow to resume flow from action-state or decision-state? The flow that I need to implement requires jumping off the flow to click some link in the email. I have the controller that handles the email link and I'm trying to resume previous flow, but not from the last view state. I have something like this

<view-state id="start>
    <transition on="submit" to="handleStep1"/>
</view-state>

<action-state id="handleStep1"/>
    <evaluate expression="a.something()"/>
    <transition on="emailSent" to="show-email-sent"/>
    <transition on="changeSomething" to="show-change"/>
</action-state>

<view-state id="show-email-sent" view="emailSentPage">
</view-state>

<view-state id="show-change" view="showChangePage">
</view-state>

When action state decides to send out the email, user is show the email sent page. Now he will click the link in the email, and he should get back to the action state which will decide that now he can go to "show-change" page. I am able to resume flow by getting the flowRequestContext.getFlowExecutionUrl() and then using it in the controller that handles the email click, but this url always redirects to the view-state (depending on when I save its value it points to the starting view-state or the email-sent view state. How can I resume the flow from the action-state? Or maybe other idea how to handle such case?


Solution

  • You could add a parameter in the link in your email, i.e. http://yoursite.com/yourflow?resume=true

    then, add an non required input in your flow:

    <input name="resume" required="false" type="boolean"/>
    

    add a decision-state to deal with it:

    <decision-state id="resumeOrNotResume">
        <if test="resume == null || !resume" then="start" else="showChange"/>
    </decision-state>
    

    and set it as a start state:

    <flow start-state="resumeOrNotResume">