Spring WebFlow (i)

Source: Internet
Author: User

Excerpted from http://hengstart.iteye.com/blog/819748

Spring Webflow has a higher level of focus than sping MVC or Structs. Not just focus on how e constructs the Web interface, but focuses more on the process, which is flow.

In spring Webflow, each flow includes several steps, called ' State '. There's a view,view inside each step. Event handling is performed by state. These events trigger transactions that jump to the other state, depending on the configuration previously set.

In spring Webflow, Flow's settings are expressed in an XML file.
The XML definition for Spring Webflow:
Flow Label:<flow/> is the root element, and all definitions begin with this element.
State Label:<view-state/> is used to indicate a state with view. In this tab, you specify the location of the file that describes the view. This location is customary and is specified by the ID of the setting. For example <view-state id= "Enterbookdetails"/&gt, then the state view of the description file is enterbookdetails.xhtml. If the flow definition file is stored under the/web-inf/xxxx/booking/directory, then the definition file for this view is/web-inf/xxxx/booking/enterbookdetails.xhtml.
Transaction Label:<transaction/> is a sub-label of View-state, which defines a page steering, such as <transaction on= "Submit" to= "reviewbooking"/&GT; It is stated that when the submit event is triggered, go to the following state, and the ID of the reviewbooking.
end-state Label:<end-state/> this represents the exit of flow, if a transaction points to a end-state tag, the flow is over. A flow can have multiple end-state tags that represent 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, as can be seen from the above, View-state, transaction, End-state label just represents flow flow, page jump, There are no operations that describe the business logic. The action is used to invoke these business logic operations.
In the next few points, we can invoke the action:
At the beginning of 1.Flow,
2. When you enter the state
3.View rendering
4.transaction Execution Time
5.state at the time of exit
At the end of 6.Flow

evaluate: This tag is probably the most commonly used tag in action, using a spring-defined expression to determine which spring bean the action is to invoke, and then return the value, what the return type is.
Example: <evaluate expression= "Bookingservice.findhotels (Searchcriteria)" result= "Flowscope.hotels" result-type= " Datamodel "/> This action needs to call Bookingservice the findhotels of this bean, and the parameter passed in is Searchcriteria this bean, The returned result is the data model of Flowscope (which is the data model of the flow that belongs to), which is mentioned later in this hotels.

A complete example of an XML file that contains an 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= "Hotelid"/>
<on-start>
<evaluate expression= "bookingservice.createbooking (hotelid,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>

Spring WebFlow (i)

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.