There are several implicit variables you may reference from within a flow. These variables are discussed in this section.
Keep in mind this general rule. Variables referring to data scopes (flowScope, viewScope, requestScope, etc.) should only be used when assigning a new variable to one of the scopes.
For example when assigning the result of the call to bookingService.findHotels(searchCriteria) to a new variable called "hotels" you must prefix it with a scope variable in order to let Web Flow know where you want it stored:
<?xml version="1.0" encoding="UTF-8"?> <flow xmlns="http://www.springframework.org/schema/webflow" ... > <var name="searchCriteria" class="org.springframework.webflow.samples.booking.SearchCriteria" /> <view-state id="reviewHotels"> <on-render> <evaluate expression="bookingService.findHotels(searchCriteria)" result="viewScope.hotels" /> </on-render> </view-state> </flow>
However when setting an existing variable such as "searchCriteria" in the example below, you reference the variable directly without prefixing it with any scope variables:
<?xml version="1.0" encoding="UTF-8"?> <flow xmlns="http://www.springframework.org/schema/webflow" ... > <var name="searchCriteria" class="org.springframework.webflow.samples.booking.SearchCriteria" /> <view-state id="reviewHotels"> <transition on="sort"> <set name="searchCriteria.sortBy" value="requestParameters.sortBy" /> </transition> </view-state> </flow>
The following is the list of implicit variables you can reference within a flow definition:
Use flowScope to assign a flow variable.
Flow scope gets allocated when a flow starts and destroyed when the flow ends. With the default
implementation, any objects stored in flow scope need to be Serializable.
<evaluate expression="searchService.findHotel(hotelId)" result="flowScope.hotel" />
Use viewScope to assign a view variable.
View scope gets allocated when a view-state enters and destroyed when the state exits.
View scope is only referenceable from within a view-state. With the
default implementation, any objects stored in view scope need to be Serializable.
<on-render>
<evaluate expression="searchService.findHotels(searchCriteria)" result="viewScope.hotels"
result-type="dataModel" />
</on-render>
Use requestScope to assign a request variable.
Request scope gets allocated when a flow is called and destroyed when the flow returns.
<set name="requestScope.hotelId" value="requestParameters.id" type="long" />
Use flashScope to assign a flash variable.
Flash scope gets allocated when a flow starts, cleared after every view render, and destroyed when the
flow ends. With the default implementation, any objects stored in flash scope need to be Serializable.
<set name="flashScope.statusMessage" value="'Booking confirmed'" />
Use conversationScope to assign a conversation variable.
Conversation scope gets allocated when a top-level flow starts and destroyed when the top-level flow ends.
Conversation scope is shared by a top-level flow and all of its subflows. With the default
implementation, conversation scoped objects are stored in the HTTP session and should generally be
Serializable to account for typical session replication.
<evaluate expression="searchService.findHotel(hotelId)" result="conversationScope.hotel" />
Use requestParameters to access a client request parameter:
<set name="requestScope.hotelId" value="requestParameters.id" type="long" />
Use currentEvent to access attributes of the current Event:
<evaluate expression="booking.guests.add(currentEvent.attributes.guest)" />
Use currentUser to access the authenticated Principal:
<evaluate expression="bookingService.createBooking(hotelId, currentUser.name)"
result="flowScope.booking" />
Use messageContext to access a context for retrieving and creating flow execution messages, including error and success messages.
See the MessageContext Javadocs for more information.
<evaluate expression="bookingValidator.validate(booking, messageContext)" />
Use resourceBundle to access a message resource.
<set name="flashScope.successMessage" value="resourceBundle.successMessage" />
Use flowRequestContext to access the RequestContext API, which is a representation of the current flow request.
See the API Javadocs for more information.
Use flowExecutionContext to access the FlowExecutionContext API, which is a representation of the current flow state.
See the API Javadocs for more information.
Use flowExecutionUrl to access the context-relative URI for the current flow execution view-state.