Spring WebFlow (1), springwebflow

Source: Internet
Author: User

Spring WebFlow (1), springwebflow

From http://hengstart.iteye.com/blog/819748

Spring WebFlow focuses at a higher level than Sping MVC or Structs. Not only focus on how e builds Web interfaces, but also on processes, that is, Flow.

In Spring WebFlow, each Flow includes several steps, called 'state '. Each step contains a View, and the event processing in the View is executed by the State. These events will trigger some transactions. These transactions will jump to other states based on the previously set configuration.

In Spring WebFlow, flow settings are represented by XML files.
XML definition of Spring WebFlow:
Flow tag: <Flow/> is the root element. All definitions start with this element.
State tag: <View-state/> indicates a State with a View. In this label, the location of the file used to describe the View is specified. This location is customary and is specified by the Set id. For example, <view-state id = "enterBookDetails"/>, the metadata file of the stateview is enterbookdetails.xhtml. If the Flow definition file is stored under the/WEB-INF/xxxx/booking/directory, the definition file for this View is/WEB-INF/xxxx/booking/enterBookDetails.xhtml.
Transaction tag: <Transaction/> is a sub-tag of view-state and defines a page transition, for example, <transaction on = "submit" to = "reviewBooking"/>, it indicates that when the submit event is triggered, it is transferred to the following state, and the id of the switched state is reviewBooking.
End-state label: <End-state/> indicates the exit of the flow. If a transaction points to an end-state tag, the flow has ended. A flow can have multiple end-state labels, Indicating multiple exits.
An example of a complete XML file:
<Flow xmlns = "http://www.springframework.org/schema/webflow"
Xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance"
Xsi: schemaLocation = "http://www.springframework.org/schema/webflow
Http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd>
<View-state id = "enterBookingDetails">
<Transition on = "submit" to = "reviewBooking"/>
</View-state>
<View-state id = "reviewBooking">
<Transition on = "confirm" to = "bookingConfirmed"/>
<Transition on = "revise" to = "enterBookingDetails"/>
<Transition on = "cancel" to = "bookingCancelled"/>
</View-state>
<End-state id = "bookingConfirmed"/>
<End-state id = "bookingCancelled"/>
</Flow>

Actions: A very important concept in Spring WebFlow. It can be seen from the above that the view-state, transaction, and end-state labels only represent the Flow of the Flow, page Jump, it does not describe the operation of the business logic. Action is used to call these business logic operations.
In the following points, we can call Action:
1. When Flow starts
2. When entering the State
3. When the View is rendered
4. When transaction is executed
5. When the state exits
6. When Flow ends

Evaluate: This label may be the most commonly used label in Action. Use the Spring-defined expression to determine which Spring Bean method an Action calls, the return value, and the return type.
Example: <evaluate expression = "bookingService. findHotels (searchCriteria) "result =" flowScope. hotel "result-type =" dataModel "/>, it indicates that this action needs to call the findHotels method of the bean bookingService. The input parameter is the bean searchCriteria, the returned result is the hotels Data Model in flowScope (this is the data model of the Flow) (this will be mentioned later ).

An example of a complete xml file containing Action
<Flow xmlns = "http://www.springframework.org/schema/webflow"
Xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance"
Xsi: schemaLocation = "http://www.springframework.org/schema/webflow
Http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd>
<Input name = "Upload ID"/>
<On-start>
<Evaluate expression = "bookingService. createBooking (Region ID, currentUser. name)" result = "flowScope. booking"/>
</On-start>
<View-state id = "enterBookingDetails">
<Transition on = "submit" to = "reviewBooking"/>
</View-state>
<View-state id = "reviewBooking">
<Transition on = "confirm" to = "bookingConfirmed"/>
<Transition on = "revise" to = "enterBookingDetails"/>
<Transition on = "cancel" to = "bookingCancelled"/>
</View-state>
<End-state id = "bookingConfirmed"/>
<End-state id = "bookingCancelled"/>
</Flow>

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.