How to load states attributes of a flow in Spring Webflow

Now you can read a mini tutorial on Spring Webflow. How to load a state attribute from a flow definition.
From the requestContext (of RequestContext class) we can load, for example, the current state.

StateDefinition currentState = requestContext.getCurrentState();

Now we can load an attribute, for example “caption”, defined in the following piece of xml flow definition file:

<view-state id="result_id" view="result_view">
<attribute name="caption" value="Result"></attribute>
<!-- Transitions -->
</view-state>

with this code:

AttributeMap attributes = stateDefinition.getAttributes();
String caption = null;
if ((attributes != null) &&
 (attributes.getString("caption") != null)) {
  caption = attributes.getString("caption");
}

One Response to “How to load states attributes of a flow in Spring Webflow”

  1. […] « How to load states attributes of a flow in Spring Webflow […]

Leave a Reply