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

Flow Registry

Place where all the flow definitions in your application is stored with a unique identifier is called the Flow Registry. The flows are typically stored in your web application under the WEB-INF folder as these cannot be accessed through the browser URL. The flows can be registered one by one as shown in Listing 14-33 below or by using appropriate wildcard pattern which registers all the flows at once as shown in Listing 14-34 below.

Listing 14-33. Registering flow one by one

Listing 14-34. Registering flows at once using wildcard patterns

The flow registeries can also have a parent-child relationship for high level of reuse as shown in Listing 14-35 below. Use the “parent” attribute in sub-flow flow registries for achieving this.

Listing 14-35. Parent-child relationship in flow registry settings

Predefined Variables

There are predefined variable which a flow can reference as the case may be. These can be summarized as shown in Table 14-5 below.

Table 14-5. Predefined variables which can be used in Spring Web Flow

Predefined Variable Description
resourceBundle Used to get text messages configured in the properties file inside the flow configuration
messageContext The context which the text message uses to get the various details
requestParameters To access the HTTP request parameters
currentUser Variable storing the executing user’s principal attributes
currentEvent Variable storing the attributes of current event being executed
flowRequestContext Similar to message context, this variable gives the context of the flow request being executed
flowExecutionContext Variable storing the context of the flow execution
flowExecutionUrl The URL of the current view-state
externalContext The context which is external to the flow

Securing Web Flow

Spring Web Flow integrates well with the famous Spring Security project in all aspects. Once the integration is made, you can use the <secured> tag to achieve security in “states”, “transitions” and “flows” of Spring Web Flow as shown in Listing 14-36 below as a sample.

Listing 14-36. Achieving security in Spring Web Flow

If the user doesn’t have the necessary credentials to access, AccessDeniedException is throws and according to the Spring Secuirty configuration, it will be handled accordingly.

Page Visitors: 8013

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 *