Search code examples
javaspringspring-webflowspring-webflow-2

Transition To Next State Without Any Conditions


I'm a newbie to web flow. It is possible to immediately transition to the next view state without any evaluation or "on" attribute.

Current Behaviour

The flow should be:

(1) showContactForm: user clicks submit

(2) the sendingMessage page is displayed.

(3) the sendMessge method is invoked in the action-state

(4) the messageSent page is displayed

Desired Behavior

The flow is stopping at the sendingMessage view state and not progressing to the sendMessage action state.

<var name="message" class="com.offers.dao.Message" />

<view-state id="showContactForm" model="message">
    <transition on="send" to="sendingMessage"></transition>
</view-state>

<view-state id="sendingMessage">
        <transition to="sendMessage"></transition>      
</view-state>

<action-state id="sendMessage">
    <evaluate expression="userService.sendMessage(message)"></evaluate>
    <transition to="messageSent"></transition>
</action-state>

<view-state id="messageSent" model="message">
</view-state>


Solution

  • View state requires user interaction. It can only be transitioned to next state based on some user event. You might need to use some java script to display sending message progress bar (instead of a separate view) when the user clicks on send button and transition directly to <action-state id="sendMessage">