Spring Web Flow

org.springframework.webflow.engine
Class SubflowState

java.lang.Object
  extended by org.springframework.webflow.core.AnnotatedObject
      extended by org.springframework.webflow.engine.State
          extended by org.springframework.webflow.engine.TransitionableState
              extended by org.springframework.webflow.engine.SubflowState
All Implemented Interfaces:
Annotated, StateDefinition, TransitionableStateDefinition

public class SubflowState
extends TransitionableState

A transitionable state that spawns a subflow when executed. When the subflow this state spawns ends, the ending result is used as grounds for a state transition out of this state.

A subflow state may be configured to map input data from its flow -- acting as the parent flow -- down to the subflow when the subflow is spawned. In addition, output data produced by the subflow may be mapped up to the parent flow when the subflow ends and the parent flow resumes. See the SubflowAttributeMapper interface definition for more information on how to do this. The logic for ending a subflow is located in the EndState implementation.

Author:
Keith Donald, Erwin Vervaet
See Also:
SubflowAttributeMapper, EndState

Field Summary
 
Fields inherited from class org.springframework.webflow.engine.State
logger
 
Fields inherited from class org.springframework.webflow.core.AnnotatedObject
CAPTION_PROPERTY, DESCRIPTION_PROPERTY
 
Constructor Summary
SubflowState(Flow flow, java.lang.String id, Expression subflow)
          Create a new subflow state.
 
Method Summary
protected  void appendToString(org.springframework.core.style.ToStringCreator creator)
          Subclasses may override this hook method to print their internal state to a string.
protected  void doEnter(RequestControlContext context)
          Specialization of State's doEnter template method that executes behaviour specific to this state type in polymorphic fashion.
 boolean handleEvent(RequestControlContext context)
          Called on completion of the subflow to handle the subflow result event as determined by the end state reached by the subflow.
 void setAttributeMapper(SubflowAttributeMapper attributeMapper)
          Set the attribute mapper used to map model data between the parent and child flow.
 
Methods inherited from class org.springframework.webflow.engine.TransitionableState
exit, getExitActionList, getRequiredTransition, getTransition, getTransitions, getTransitionSet
 
Methods inherited from class org.springframework.webflow.engine.State
doPreEntryActions, enter, equals, getEntryActionList, getExceptionHandlerSet, getFlow, getId, getOwner, handleException, hashCode, isStartState, isViewState, toString
 
Methods inherited from class org.springframework.webflow.core.AnnotatedObject
getAttributes, getCaption, getDescription, setCaption, setDescription
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.springframework.webflow.definition.StateDefinition
getId, getOwner, isViewState
 
Methods inherited from interface org.springframework.webflow.core.Annotated
getAttributes, getCaption, getDescription
 

Constructor Detail

SubflowState

public SubflowState(Flow flow,
                    java.lang.String id,
                    Expression subflow)
             throws java.lang.IllegalArgumentException
Create a new subflow state.

Parameters:
flow - the owning flow
id - the state identifier (must be unique to the flow)
subflow - the subflow to spawn
Throws:
java.lang.IllegalArgumentException - when this state cannot be added to given flow, e.g. because the id is not unique
See Also:
setAttributeMapper(SubflowAttributeMapper)
Method Detail

setAttributeMapper

public void setAttributeMapper(SubflowAttributeMapper attributeMapper)
Set the attribute mapper used to map model data between the parent and child flow.


doEnter

protected void doEnter(RequestControlContext context)
                throws FlowExecutionException
Specialization of State's doEnter template method that executes behaviour specific to this state type in polymorphic fashion.

Entering this state, creates the subflow input map and spawns the subflow in the current flow execution.

Specified by:
doEnter in class State
Parameters:
context - the control context for the currently executing flow, used by this state to manipulate the flow execution
Throws:
FlowExecutionException - if an exception occurs in this state

handleEvent

public boolean handleEvent(RequestControlContext context)
Called on completion of the subflow to handle the subflow result event as determined by the end state reached by the subflow.

Overrides:
handleEvent in class TransitionableState
Parameters:
context - the flow execution control context

appendToString

protected void appendToString(org.springframework.core.style.ToStringCreator creator)
Description copied from class: State
Subclasses may override this hook method to print their internal state to a string. This default implementation does nothing.

Overrides:
appendToString in class TransitionableState
Parameters:
creator - the toString creator, to print properties to string
See Also:
State.toString()

Spring Web Flow