diff --git a/spring-webflow-reference/src/actions.xml b/spring-webflow-reference/src/actions.xml new file mode 100644 index 00000000..046de63e --- /dev/null +++ b/spring-webflow-reference/src/actions.xml @@ -0,0 +1,237 @@ + + + Executing actions + + Introduction + + This chapter shows you how to use the action-state element to control the execution of an action at a point within a flow. + It will also show how to use the decision-state element to make a flow routing decision. + Finally, several examples of invoking actions from the various points possible within a flow will be discussed. + + + + Defining action states + + Use the action-state element when you wish to invoke an action, then transition to another state based on the action's outcome: + + + + + + +]]> + + + The full example below illustrates a interview flow that uses the action-state above to determine if more answers are needed to complete the interview: + + + + + + + + + + + + + + + + + + + + + + + + +]]> + + + + Defining decision states + + Use the decision-state element as an alternative to the action-state to make a routing decision using a convenient if/else syntax. + The example below shows the moreAnswersNeeded state above now implemented as a decision state instead of an action-state: + + + + +]]> + + + + Action outcome event mappings + + Actions often invoke methods on plain Java objects. + When called from action-states and decision-states, these method return values can be used to drive state transitions. + Since transitions are triggered by events, a method return value must first be mapped to an Event object. + The following table describes how common return value types are mapped to Event objects: + + + Action method return value to event id mappings + + + + + + Method return type + Mapped Event identifier expression + + + + + java.lang.Boolean + yes (for true), no (for false) + + + java.lang.Enum + the Enum name + + + java.lang.String + the String value + + + any other type + success + + + +
+ + This is illustrated in the example action state below, which invokes a method that returns a boolean value: + + + + + + +]]> + +
+ + Action execution examples + + on-start + + The following example shows an action that creates a new Booking object by invoking a method on a service: + + + + + + + + + +]]> + + + + on-entry + + The following example shows a state entry action that sets the special fragments variable that causes the view-state to render a partial fragment of its view: + + + + + +]]> + + + + on-exit + + The following example shows a state exit action that releases a lock on a record being edited: + + + + + + + + + + + +]]> + + + + on-end + + The following example shows the equivalent object locking behavior using flow start and end actions: + + + + + + + + + + + + + + + + + + + +]]> + + + + on-render + + The following example shows a render action that loads a list of hotels to display before the view is rendered: + + + + + + + + +]]> + + + + on-transition + + The following example shows a transition action adds a subflow outcome event attribute to a collection: + + + + + +]]> + + + +
\ No newline at end of file