1. In spring Web flow, the process is defined by three main elements: state, transfer, and process data.
Status is the place where events occur in the process, similar to the stops in the road trip, and transfers are similar to the roads connected to these sites
2. Status
Spring Web Flow defines 5 different kinds of states:
Status type |
Role |
Behavior (Action) |
Is where the logic of the process takes place |
Decision Making (decision) |
The process is divided into two directions, which determine the direction of the process based on the evaluation results of the process data |
Ending (end) |
Is the last stop of the process, and once it enters the end state, the process ends. |
Sub-process (Subflow) |
A new process is launched in the context of the current ongoing process |
Views (view) |
Pauses the process and invites the user to participate in the process |
(1) View state
View state is used to present information to the user and to make the user work in the process, and the actual view implementation can be any type of view supported by spring, but is usually implemented with JSP. ,<view-state> user-defined view state in a process-defined XML file
<view-state id= "Welcome"/>
Where ID has two meanings, one is to indicate this state within the process, and the second is to specify the name of the logical view to show when the process is in this state, if you want to display a different view, you can do the following:
<view-state id= "Welcome" view= "Greeting"/>
If the process presents a form to the user, you may want to indicate which object the form is bound to, as follows:
<view-state id= "takepayment" model= "Flowscope.paymentdetails"/>
(2) Behavior status
The application itself is executing the task, and in the process definition XML file, the behavior state is declared using the <action-state> element, as shown in the following example:
<action-state id= "Saveorder" > <evaluate expression= "Pizzaflowactions.saveoder (Order)"/> < Transition to= "Thankyou"/></action-state>
The <evaluate> element gives the behavior state to do, and the expression property specifies the expressions to be evaluated when entering this state
(3) Decision State
The decision state enables two branches to be generated when the process executes, and the decision evaluates a Boolean expression and then selects one of the two states. Examples are as follows:
<decision-state id= "Checkdeliveryarea" > <if test= "Pizzaflowactions.checkdeliveryarea ( Customer.zipcode) "Then " Addcustomer " Else" deliverywarning "/></decision-state>
(4) Sub-process status
Another process is called in one of the executing processes, as in the following example:
<subflow-state id= "Order" Subflow "Pizza/order" > <input name= "Order" value= "order"/> <transition on= "ordercreated" to= "Payment"/></subflow-state>
(5) End status
The end of the process is specified, as in the following example:
<end-state id= "Customerready"/>
3. Transfer, global transfer
The transfer connects to the state in the process, in addition to the end state, there is at least one transfer, so that it is possible to go wherever the process is completed.
The transfer needs to be defined using the <transition> element, which acts as a child of each state, as shown in the following example:
<transition to= "Customerready"/>
property to is used to specify the next state of the process, using only the To property, then this transfer is the default transfer option for the current state. You can also use the On property to specify the event that triggered the transfer.
<transition on = "phoneentered" to= "Lookupcustomer"/>
Repeating a common transfer in multiple states, you can define it as a global transfer, so that all States in the process will have this global transition by default, as shown in the following example:
<global-transitions> <transition on= "Cancel" to= "EndState"/></global-transitions>
4. Process data
(1) Defining variables
(2) Define scope of process data
Spring Web Flow Learning Note (2)-components of the process