org.springframework.webflow.executor.mvc
Class FlowController

java.lang.Object
  extended by org.springframework.context.support.ApplicationObjectSupport
      extended by org.springframework.web.context.support.WebApplicationObjectSupport
          extended by org.springframework.web.servlet.support.WebContentGenerator
              extended by org.springframework.web.servlet.mvc.AbstractController
                  extended by org.springframework.webflow.executor.mvc.FlowController
All Implemented Interfaces:
org.springframework.beans.factory.InitializingBean, org.springframework.context.ApplicationContextAware, org.springframework.web.context.ServletContextAware, org.springframework.web.servlet.mvc.Controller

public class FlowController
extends org.springframework.web.servlet.mvc.AbstractController
implements org.springframework.beans.factory.InitializingBean

Point of integration between Spring Web MVC and Spring Web Flow: a Controller that routes incoming requests to one or more managed flow executions.

Requests into the web flow system are handled by a FlowExecutor, which this class delegates to using a FlowRequestHandler helper. Consult the JavaDoc of that class for more information on how requests are processed.

Note: a single FlowController may execute all flows of your application.

Usage example:

     <!--
         Exposes flows for execution at a single request URL.
         The id of a flow to launch should be passed in by clients using
         the "_flowId" request parameter:
         e.g. /app.htm?_flowId=flow1
     -->
     <bean name="/app.htm" class="org.springframework.webflow.executor.mvc.FlowController">
         <property name="flowExecutor" ref="flowExecutor"/>
     </bean>
 

It is also possible to customize the FlowExecutorArgumentHandler strategy to allow for different types of controller parameterization, for example perhaps in conjunction with a REST-style request mapper (see RequestPathFlowExecutorArgumentHandler).

Author:
Erwin Vervaet, Keith Donald
See Also:
FlowExecutor, FlowRequestHandler, FlowExecutorArgumentHandler

Field Summary
 
Fields inherited from class org.springframework.web.servlet.support.WebContentGenerator
METHOD_GET, METHOD_HEAD, METHOD_POST
 
Fields inherited from class org.springframework.context.support.ApplicationObjectSupport
logger
 
Constructor Summary
FlowController()
          Create a new flow controller.
 
Method Summary
 void afterPropertiesSet()
           
protected  FlowRequestHandler createRequestHandler()
          Factory method that creates a new helper for processing a request into this flow controller.
 FlowExecutorArgumentHandler getArgumentHandler()
          Returns the flow executor argument handler used by this controller.
 FlowExecutor getFlowExecutor()
          Returns the flow executor used by this controller.
protected  org.springframework.web.servlet.ModelAndView handleRequestInternal(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
           
 void setArgumentHandler(FlowExecutorArgumentHandler argumentHandler)
          Sets the flow executor argument handler to use.
 void setDefaultFlowId(java.lang.String defaultFlowId)
          Sets the identifier of the default flow to launch if no flowId argument can be extracted by the configured FlowExecutorArgumentHandler during request processing.
 void setFlowExecutor(FlowExecutor flowExecutor)
          Sets the flow executor to use; setting this property is required.
protected  org.springframework.web.servlet.ModelAndView toModelAndView(ResponseInstruction responseInstruction, ExternalContext context)
          Create a ModelAndView object based on the information in the selected response instruction.
 
Methods inherited from class org.springframework.web.servlet.mvc.AbstractController
handleRequest, isSynchronizeOnSession, setSynchronizeOnSession
 
Methods inherited from class org.springframework.web.servlet.support.WebContentGenerator
applyCacheSeconds, applyCacheSeconds, cacheForSeconds, cacheForSeconds, checkAndPrepare, checkAndPrepare, getCacheSeconds, getSupportedMethods, isRequireSession, isUseCacheControlHeader, isUseExpiresHeader, preventCaching, setCacheSeconds, setRequireSession, setSupportedMethods, setUseCacheControlHeader, setUseExpiresHeader
 
Methods inherited from class org.springframework.web.context.support.WebApplicationObjectSupport
getServletContext, getTempDir, getWebApplicationContext, isContextRequired, setServletContext
 
Methods inherited from class org.springframework.context.support.ApplicationObjectSupport
getApplicationContext, getMessageSourceAccessor, initApplicationContext, requiredContextClass, setApplicationContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FlowController

public FlowController()
Create a new flow controller. Allows bean style usage.

See Also:
setFlowExecutor(FlowExecutor), setArgumentHandler(FlowExecutorArgumentHandler)
Method Detail

getFlowExecutor

public FlowExecutor getFlowExecutor()
Returns the flow executor used by this controller.

Returns:
the flow executor

setFlowExecutor

public void setFlowExecutor(FlowExecutor flowExecutor)
Sets the flow executor to use; setting this property is required.

Parameters:
flowExecutor - the fully configured flow executor to use

getArgumentHandler

public FlowExecutorArgumentHandler getArgumentHandler()
Returns the flow executor argument handler used by this controller. Defaults to RequestParameterFlowExecutorArgumentHandler.

Returns:
the argument handler

setArgumentHandler

public void setArgumentHandler(FlowExecutorArgumentHandler argumentHandler)
Sets the flow executor argument handler to use. The default is RequestParameterFlowExecutorArgumentHandler.

Parameters:
argumentHandler - the fully configured argument handler

setDefaultFlowId

public void setDefaultFlowId(java.lang.String defaultFlowId)
Sets the identifier of the default flow to launch if no flowId argument can be extracted by the configured FlowExecutorArgumentHandler during request processing.

This is a convenience method that sets the default flow id of the controller's argument handler. Don't use this when using setArgumentHandler(FlowExecutorArgumentHandler).


afterPropertiesSet

public void afterPropertiesSet()
Specified by:
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean

handleRequestInternal

protected org.springframework.web.servlet.ModelAndView handleRequestInternal(javax.servlet.http.HttpServletRequest request,
                                                                             javax.servlet.http.HttpServletResponse response)
                                                                      throws java.lang.Exception
Specified by:
handleRequestInternal in class org.springframework.web.servlet.mvc.AbstractController
Throws:
java.lang.Exception

createRequestHandler

protected FlowRequestHandler createRequestHandler()
Factory method that creates a new helper for processing a request into this flow controller. The handler is a basic template encapsulating reusable flow execution request handling workflow. This implementation just creates a new FlowRequestHandler.

Returns:
the controller helper

toModelAndView

protected org.springframework.web.servlet.ModelAndView toModelAndView(ResponseInstruction responseInstruction,
                                                                      ExternalContext context)
Create a ModelAndView object based on the information in the selected response instruction. Subclasses can override this to return a specialized ModelAndView or to do custom processing on it.

Parameters:
responseInstruction - the response instruction to convert
Returns:
a new ModelAndView object


Copyright © 2004-2007. All Rights Reserved.