4. Creating the Model for Spring Web Flow

PROBLEM

In the context of Spring Web Flow, a model serves the same function as a model in Spring MVC. The model generally represents the data that will be passed to and from a View State (instead of an Operation) and the view. Spring Web Flow supports various options and patterns for defining the data that can be passed back and forth, and a typical Spring Web Flow application may use a combination of these options. The flexibility of Spring Web Flow to have fine-grained control for defining models is very powerfull, however the definition of the models can be difficult because the models are defined and used in xml (flow).

SOLUTION

Through the use of the Skyway Web Flow editor, defining models is much simpler because the flow is represented in a diagram. This is very effective for defining models and to understand the use of models in a Spring web Flow implementation.

HOW IT WORKS

Once again a model generally refers to the data that is pased to and from a web flow View State.

Figure 2.8. Model (MVC)

Model (MVC)

Steps for defining a Model for a Spring Web Flow view state:

  1. In a flow diagram, identify a View State for configuring a model.

  2. For the model parameter, specify the variable that should be used for the model. The model will be the commandObject that can be used in the JSP to display data to and/or solicit data from the end-user.

Figure 2.9. Spring Web Flow Model (Example 1) - Model Config

Spring Web Flow Model (Example 1) - Model Config

RELATED RECIPES

  1. Creating the Controller using Spring Web Flow

  2. Creating the View for Spring MVC