Tutorial library
Skyway Builder Spring Web Flow Tutorial, Version 6.3
A guided build of a multi page journey with Spring Web Flow, including validation, flow scope and a confirmation state.
The Spring Web Flow tutorial extends the customer application from the MVC tutorial. It turns a single edit form into a guided journey with an introduction page, a form, a review step and a confirmation. Each step is a state, and each move between steps is a transition.
What the tutorial covers
- Creating a flow definition in the model.
- Adding view states and an action state.
- Sharing a form object through flow scope.
- Validating on a transition and returning to the form.
- Ending the flow with a confirmation view.
Designing the journey
Draw the journey before modelling it. A short pencil sketch of the states and transitions prevents most rework. Keep the number of states small, and name each transition after the event that triggers it. The flow diagram in the editor should read like the sketch.
Validation and error handling
Attach the validator to the transition that leaves the form. On failure the flow stays on the form and shows the messages. Do not clear the form on failure. A user who must retype a long form is unlikely to finish the journey.
Where to go next
Read the flow recipe pages for the details behind each step, then review the sample flow figure. The reference book collects the flow elements and their attributes in one place.