Spring Book – Chapter 14 – Spring MVC and Spring Web Flow

Flow

A flow can be considered as a task which a user wishes to perform in your web application like BookCargo, GetLoyaltyPoints etc. to name a few. The flow can consists of several steps grouped together to achieve a task as a whole. In Listing 14-21 below shows declaration of a typical Web Flow in the configuration file of Spring Web Flow.

Listing 14-21. Declaration of a sample Web Flow in configuration file

A flow consists of following elements as summarized below:

  • States – the steps in a typical flow. There are various states which a flow can have as summarized below:
    • View State – used to display useful information to the user. The actual view implementation can be anything which the Spring MVC framework supports. View state is declared as shown in Listing 14-22 below.

Listing 14-22. Declaring view state in Spring Web Flow

  • Action State – state where the actual work happens. In this state the method in the Spring managed bean is called where the actual work happens. Listing 14-23 below shows the declaration of action state.

Listing 14-23. Declaring action state in Spring Web Flow

  • Decision State – state where according to decision it can branch out and flow in a different direction. Listing 14-24 below shows the declaration of decision state in the Spring Web Flow.

Listing 14-24. Declaring decision state in Spring Web Flow

  • Sub-flow State – allows calling another flow within the parent flow. Listing 14-25 below shows declaring a sub-flow in Spring Web Flow.

Listing 14-25. Declaring sub-flow in Spring Web Flow

  • End State – designates end of a flow and is declared as show in Listing 14-26 below.

Listing 14-26. Declaring end state in Spring Web Flow

  • Transitions – the path which moves the flow from one state to other. You can also configure transitions which are global in nature as shown in Listing 14-27 below.

Listing 14-27. Declaring global transition in the Spring Web Flow configuration file

  • Actions – the actual behavior at the various states in a flow.

Page Visitors: 8102

The following two tabs change content below.
Tomcy John

Tomcy John

Blogger & Author at javacodebook
He is an Enterprise Java Specialist holding a degree in Engineering (B-Tech) with over 10 years of experience in several industries. He's currently working as Principal Architect at Emirates Group IT since 2005. Prior to this he has worked with Oracle Corporation and Ernst & Young. His main specialization is on various web technologies and acts as chief mentor and Architect to facilitate incorporating Spring as Corporate Standard in the organization.
Tomcy John

Latest posts by Tomcy John (see all)

Leave a Reply

Your email address will not be published. Required fields are marked *