Spring Web Flow Learning notes (1)

Source: Internet
Author: User

1.Spring Web Flow is an extension of Spring MVC that supports the development of process-based applications that decouple the definition of a process from the classes and views that implement the behavior of the process.

2. Although spring Web flow is a subproject of the spring framework, it is not part of the spring framework.

3. Using Web Flow in spring

(1) Weaving process Actuator

The process executor drives the execution of the process, and when the user enters a process, the process executor creates and initiates a process execution instance for the user, and when the process is paused (such as when the user presents the view), the process executor resumes the process after the user has performed the operation. Create the process executor as follows:

<flow:flow-executor id= "Flowexecutor" flow-registry= "Flowregistry"/>

Although the process executor is responsible for creating and executing the process, it is not responsible for loading the process definition, which rests on the process registry

(2) Configure the Process registration form

The work of the process registry is to load the process definition and let the process executor use them, with the following code:

<flow:flow-registry id= "Flowregistry" base-path= "/web-inf/flows" >    <flow:flow-location-pattern value= "*-flow.xml"/></flow:flow-registry>

The registry looks for the process definition under the/web-inf/flows directory, and any XML file that is-flow.xml is considered a process definition, and all processes are referenced by ID. The process ID defined by <flow:flow-location-pattern> is either a relative base-path path or a path represented by an asterisk.

In another way, you can remove the Base-path property, but instead display the location of the file that declares the process definition:

<flow:flow-registry id= "Flowregistry" >    <flow:flow-location path= "Web-inf/flows/login-flow.xml"/> </flow:flow-registry>

The ID of the process is obtained from the filename of the process file, and this is login-flow.

If you want to display the specified process ID more, you can do the following:

<flow:flow-registry id= "Flowregistry" >    <flow:flow-location id= "Loginflow" path= "WEB-INF/flows/ Login-flow.xml "/></flow:flow-registry>

(3) Processing process requests

We need flowhandlermapping to help dispatcherservlet send a request for the process to spring Web flow, which is configured in the Spring application context as follows:

<bean class= "org.springframework.webflow.mvc.servlet.FlowHandlerMapping" ><property name= "Flowregistry" ref= "Flowregistry"/></bean>

Flowhandlermapping simply directs the process request to the spring Web flow, and the corresponding request is flowhandleradapter, which is equivalent to the controller in spring MVC. It is configured as follows:

<bean class= "Org.springframework.webflow.mvc.servlet.FlowHandlerAdapter" ><property name= "Flowexecutor" ref= "Flowexecutor"/></bean>

  

 

Spring Web Flow Learning notes (1)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.