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 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.
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.