Spring Web Flow 2 Reference Guide

Reference Documentation

Keith Donald

Erwin Vervaet

Jeremy Grelle

Scott Andrews

Rossen Stoyanchev

Version 2.0.3

Copies of this document may be made for your own use and for distribution to others, provided that you do not charge any fee for such copies and further provided that each copy contains this Copyright Notice, whether distributed in print or electronically.

July 2008


Table of Contents

Preface
1. Introduction
1.1. What this guide covers
1.2. What Web Flow requires to run
1.3. Where to get support
1.4. Where to follow development
1.5. How to obtain Web Flow artifacts from the SpringSource Bundle Repository
1.5.1. Accessing Web Flow with Maven
1.5.2. Accessing Web Flow with Ivy
1.6. How to obtain Web Flow artifacts from Maven Central
1.7. How to Obtain Nightly Builds
2. Defining Flows
2.1. Introduction
2.2. What is a flow?
2.3. What is the makeup of a typical flow?
2.4. How are flows authored?
2.5. Essential language elements
2.5.1. flow
2.5.2. view-state
2.5.3. transition
2.5.4. end-state
2.5.5. Checkpoint: Essential language elements
2.6. Actions
2.6.1. evaluate
2.6.1.1. Assigning an evaluate result
2.6.1.2. Converting an evaluate result
2.6.2. Checkpoint: flow actions
2.7. Input/Output Mapping
2.7.1. input
2.7.1.1. Declaring an input type
2.7.1.2. Assigning an input value
2.7.1.3. Marking an input as required
2.7.2. output
2.7.2.1. Specifying the source of an output value
2.7.3. Checkpoint: input/output mapping
2.8. Variables
2.8.1. var
2.9. Calling subflows
2.9.1. subflow-state
2.9.1.1. Passing a subflow input
2.9.1.2. Mapping subflow output
2.9.2. Checkpoint: calling subflows
3. Expression Language (EL)
3.1. Introduction
3.2. Supported EL implementations
3.2.1. Unified EL
3.2.2. OGNL
3.3. EL portability
3.4. EL usage
3.4.1. Expression types
3.4.1.1. Standard eval expressions
3.4.1.2. Template expressions
3.5. Special EL variables
3.5.1. flowScope
3.5.2. viewScope
3.5.3. requestScope
3.5.4. flashScope
3.5.5. conversationScope
3.5.6. requestParameters
3.5.7. currentEvent
3.5.8. currentUser
3.5.9. messageContext
3.5.10. resourceBundle
3.5.11. flowRequestContext
3.5.12. flowExecutionContext
3.5.13. flowExecutionUrl
3.5.14. externalContext
3.6. Scope searching algorithm
4. Rendering views
4.1. Introduction
4.2. Defining view states
4.3. Specifying view identifiers
4.3.1. Flow relative view ids
4.3.2. Absolute view ids
4.3.3. Logical view ids
4.4. View scope
4.4.1. Allocating view variables
4.4.2. Assigning a viewScope variable
4.4.3. Manipulating objects in view scope
4.5. Executing render actions
4.6. Binding to a model
4.7. Suppressing binding
4.8. Specifying bindings explicitly
4.9. Validating a model
4.9.1. Programmatic validation
4.9.1.1. Implementing a model validate method
4.9.1.2. Implementing a Validator
4.9.2. Declarative validation
4.10. Suppressing validation
4.11. Transition actions
4.12. Handling events
4.12.1. Rendering partials
4.12.2. Handling global events
4.13. Working with messages
4.13.1. Adding plain text messages
4.13.2. Adding internationalized messages
4.13.3. Using message bundles
4.14. Displaying popups
4.15. View backtracking
4.15.1. Discarding history
4.15.2. Invalidating history
5. Executing actions
5.1. Introduction
5.2. Defining action states
5.3. Defining decision states
5.4. Action outcome event mappings
5.5. Action execution examples
5.5.1. on-start
5.5.2. on-entry
5.5.3. on-exit
5.5.4. on-end
5.5.5. on-render
5.5.6. on-transition
6. Flow Managed Persistence
6.1. Introduction
6.2. Data access patterns
6.3. FlowScoped PersistenceContext
6.4. ConversationScoped PersistenceContext
6.5. ViewState PersistenceContext
7. Securing Flows
7.1. Introduction
7.2. How do I secure a flow?
7.3. The secured element
7.3.1. Security attributes
7.3.2. Matching type
7.4. The SecurityFlowExecutionListener
7.4.1. Custom Access Decision Managers
7.5. Configuring Spring Security
7.5.1. Spring configuration
7.5.2. web.xml Configuration
8. Flow Inheritance
8.1. Introduction
8.2. Is flow inheritance like Java inheritance?
8.3. Types of Flow Inheritance
8.3.1. Flow level inheritance
8.3.2. State level inheritance
8.4. Abstract flows
8.5. Inheritance Algorithm
8.5.1. Mergeable Elements
8.5.2. Non-mergeable Elements
9. System Setup
9.1. Introduction
9.2. webflow-config.xsd
9.3. Basic system configuration
9.3.1. FlowRegistry
9.3.2. FlowExecutor
9.4. flow-registry options
9.4.1. Configuring custom FlowBuilder services
9.4.1.1. conversion-service
9.4.1.2. expression-parser
9.4.1.3. view-factory-creator
9.4.2. Configuring FlowRegistry hierarchies
9.4.3. Specifying flow locations
9.4.4. Assigning custom flow identifiers
9.4.5. Assigning flow meta-attributes
9.4.6. Registering flows using a location pattern
9.5. flow-executor options
9.5.1. Attaching flow execution listeners
9.5.2. Tuning FlowExecution persistence
9.5.2.1. max-executions
9.5.2.2. max-execution-snapshots
10. Spring MVC Integration
10.1. Introduction
10.2. Configuring web.xml
10.3. Mapping URLs to Flows
10.4. Flow Handlers
10.4.1. Example FlowHandler
10.4.2. Registering the FlowHandlerAdapter
10.4.3. FlowHandler Redirects
10.5. Flow Controller
10.6. View Resolution
11. Spring JavaScript Quick Reference
11.1. Introduction
11.2. Serving Javascript Resources
11.3. Including Spring Javascript in a Page
11.4. Spring Javascript Decorations
11.5. Handling Ajax Requests
11.5.1. Handling Ajax Requests with Spring MVC Controllers
11.5.2. Handling Ajax Requests with Spring MVC + Spring Web Flow
12. JSF Integration
12.1. Introduction
12.2. Spring-centric Integration Approach
12.3. Configuring web.xml
12.4. Configuring Web Flow to render JSF views
12.5. Configuring faces-config.xml
12.6. Replacing the JSF Managed Bean Facility
12.6.1. Using Flow Variables
12.6.2. Using Scoped Spring Beans
12.6.3. Manipulating The Model
12.7. Handling JSF Events With Spring Web Flow
12.7.1. Handling JSF In-page Action Events
12.7.2. Handling JSF Action Events
12.7.3. Performing Model Validation
12.7.4. Handling Ajax Events
12.8. Enhancing The User Experience With Rich Web Forms
12.8.1. Validating a Text Field
12.8.2. Validating a Numeric Field
12.8.3. Validating a Date Field
12.8.4. Preventing an Invalid Form Submission
12.9. Third-Party Component Library Integration
12.9.1. Rich Faces Integration
12.9.2. Apache MyFaces Trinidad Integration
13. Portlet Integration
13.1. Introduction
13.2. Configuring web.xml and portlet.xml
13.3. Configuring Spring
13.3.1. Flow Handlers
13.3.2. Handler Mappings
13.3.3. Flow Handler Adapter
13.4. Portlet Views
13.5. Portlet Modes and Window States
13.5.1. Window State
13.5.2. Portlet Mode
13.6. Issues in a Portlet Environment
13.6.1. Redirects
13.6.2. Switching Portlet Modes
13.6.3. Portlets and JSF
14. Testing flows
14.1. Introduction
14.2. Extending AbstractXmlFlowExecutionTests
14.3. Specifying the path to the flow to test
14.4. Registering flow dependencies
14.5. Testing flow startup
14.6. Testing flow event handling
14.7. Mocking a subflow
15. Upgrading from 1.0
15.1. Introduction
15.2. Flow Definition Language
15.2.1. Flow Definition Updater Tool
15.2.1.1. Flow Definition Updater Tool Warnings
15.2.2. EL Expressions
15.3. Web Flow Configuration
15.3.1. Web Flow Bean Configuration
15.3.2. Web Flow Schema Configuration
15.3.2.1. flow-executor
15.3.2.2. flow-execution-listeners
15.3.2.3. flow-registry
15.3.3. Flow Controller
15.3.4. Flow Request URL Handler
15.3.5. View Resolution
15.4. New Web Flow Concepts
15.4.1. Automatic Model Binding
15.4.2. OGNL vs EL
15.4.3. Flash Scope
15.4.4. Spring Faces
15.4.5. External Redirects
A. Flow Definition Language 1.0 to 2.0 Mappings