Skip to content
Model centric tools for Spring development Community portal
Skyway PerspectivesModel driven delivery

Model reference

Reference Figure: A Sample Spring Web Flow

A sample flow with three states and two transitions. The figure shows how a form, an action and a confirmation state are connected.

A Spring Web Flow state machine with start, view, action and end states
Figure 11. A short flow: show the form, save the record, confirm the result.

A flow is a small state machine. The sample flow has a start state, a form view, an action that saves a record and a confirmation view. The whole journey fits on one screen, which makes it a good first flow to read.

States and transitions

  • Start. Creates the form object and enters the form view.
  • Form view. Renders the form and waits for the submit event.
  • Action. Calls the service and stores the saved record in flow scope.
  • Confirmation. Shows the saved record and ends the flow.

Flow scope and view scope

Values that must survive more than one view belong in flow scope. Values that are only needed for one view belong in view scope. Keep flow scope small. A flow that stores whole result sets in scope uses more memory than it needs and is harder to reason about.

Read the diagram first. Before opening the XML, follow the states in the figure. If the figure is clear, the XML is usually easy to read. If the figure is confusing, the flow needs fewer states.

Subflows keep large journeys readable. Move a repeated group of states into a subflow and call it from the main flow. The sample flow is small enough to stay flat, which makes it a useful reference for the shape of a well bounded journey.