Table of Contents
Web Flow uses EL to access its data model and to invoke actions. This chapter will familiarize you with EL syntax, configuration, and special EL variables you can reference from your flow definition.
EL is used for many things within a flow including:
Access client data such as declaring flow inputs or referencing request parameters.
Access data in Web Flow's RequestContext such as flowScope or currentEvent.
Invoke methods on Spring-managed objects through actions.
Resolve expressions such as state transition criteria, subflow ids, and view names.
EL is also used to bind form parameters to model objects and reversely to render formatted form fields from the properties of a model object. That however does not apply when using Web Flow with JSF in which case the standard JSF component lifecyle applies.
An important concept to understand is there are two types of expressions in Web Flow: standard expressions and template expressions.
The first and most common type of expression is the standard expression.
Such expressions are evaluated directly by the EL and need not be enclosed in delimiters like #{}.
For example:
<evaluate expression="searchCriteria.nextPage()" />
The expression above is a standard expression that invokes the nextPage method on the searchCriteria variable when evaluated.
If you attempt to enclose this expression in a special delimiter like #{} you will get an IllegalArgumentException.
In this context the delimiter is seen as redundant.
The only acceptable value for the expression attribute is an single expression string.
The second type of expression is a template expression.
A template expression allows mixing of literal text with one or more standard expressions.
Each standard expression block is explicitly surrounded with the #{} delimiters.
For example:
<view-state id="error" view="error-#{externalContext.locale}.xhtml" />
The expression above is a template expression.
The result of evaluation will be a string that concatenates literal text such as error- and .xhtml with the result of evaluating externalContext.locale.
As you can see, explicit delimiters are necessary here to demarcate standard expression blocks within the template.
See the Web Flow XML schema for a complete listing of those XML attributes that accept standard expressions and those that accept template expressions. You can also use F2 in Eclipse (or equivalent shortcut in other IDEs) to access available documentation when typing out specific flow definition attributes.