Class FlowHandlerAdapter
java.lang.Object
org.springframework.context.support.ApplicationObjectSupport
org.springframework.web.context.support.WebApplicationObjectSupport
org.springframework.web.servlet.support.WebContentGenerator
org.springframework.webflow.mvc.servlet.FlowHandlerAdapter
- All Implemented Interfaces:
org.springframework.beans.factory.Aware,org.springframework.beans.factory.InitializingBean,org.springframework.context.ApplicationContextAware,org.springframework.web.context.ServletContextAware,org.springframework.web.servlet.HandlerAdapter
- Direct Known Subclasses:
JsfFlowHandlerAdapter
public class FlowHandlerAdapter
extends org.springframework.web.servlet.support.WebContentGenerator
implements org.springframework.web.servlet.HandlerAdapter, org.springframework.beans.factory.InitializingBean
A custom MVC HandlerAdapter that encapsulates the generic workflow associated with executing flows in a Servlet
environment. Delegates to mapped
flow handlers to manage the interaction with executions of
specific flow definitions.- Author:
- Keith Donald, Phillip Webb
-
Field Summary
Fields inherited from class org.springframework.web.servlet.support.WebContentGenerator
HEADER_CACHE_CONTROL, METHOD_GET, METHOD_HEAD, METHOD_POST -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidprotected ServletExternalContextcreateServletExternalContext(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) Creates the servlet external context for the current HTTP servlet request.protected MutableAttributeMap<Object>defaultCreateFlowExecutionInputMap(jakarta.servlet.http.HttpServletRequest request) The default algorithm to create the flow execution input map.protected StringdefaultGetFlowId(jakarta.servlet.http.HttpServletRequest request) The default algorithm to determine the id of the flow to launch from the current request.protected voiddefaultHandleException(String flowId, FlowException e, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) The default algorithm for handling aFlowExceptionnow handled by the Web Flow system.protected voiddefaultHandleExecutionOutcome(String flowId, FlowExecutionOutcome outcome, ServletExternalContext context, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) The default algorithm for handling a flow execution outcome.Returns the configured Ajax handler.Returns the central service for executing flows.Returns the flow url handler.String[]getHosts()Return the configured hosts associated with the application.longgetLastModified(jakarta.servlet.http.HttpServletRequest request, Object handler) booleanWhether redirect sent by this handler adapter should be compatible with HTTP 1.0 clients.booleanWhether servlet relative redirects should passflow outputto the Spring MVCflash scope.org.springframework.web.servlet.ModelAndViewhandle(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, Object handler) protected booleanisRemoteHost(String targetUrl) Whether the given targetUrl has a host that is a "foreign" system in which caseHttpServletResponse.encodeRedirectURL(java.lang.String)will not be applied.protected voidsendRedirect(String url, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) Sends a redirect to the requested url usingHttpServletResponse.sendRedirect(String).Called to actually perform flow execution redirects, flow definition redirects, and external redirects.voidsetAjaxHandler(AjaxHandler ajaxHandler) Sets the configured Ajax handler.voidsetFlowExecutor(FlowExecutor flowExecutor) Sets the central service for executing flows.voidsetFlowUrlHandler(FlowUrlHandler flowUrlHandler) Sets the flow url handlervoidConfigure one or more hosts associated with the application.voidsetRedirectHttp10Compatible(boolean redirectHttp10Compatible) Set whether redirects sent by this handler adapter should be compatible with HTTP 1.0 clients.voidsetSaveOutputToFlashScopeOnRedirect(boolean saveOutputToFlashScopeOnRedirect) Set whether servlet relative redirects sent by this handler adapter should passflow outputto the Spring MVCflash scope.voidsetStatusCode(org.springframework.http.HttpStatus statusCode) Set the status code for this view.booleanMethods inherited from class org.springframework.web.servlet.support.WebContentGenerator
applyCacheControl, applyCacheSeconds, applyCacheSeconds, cacheForSeconds, cacheForSeconds, checkAndPrepare, checkRequest, getAllowHeader, getCacheControl, getCacheSeconds, getSupportedMethods, getVaryByRequestHeaders, isAlwaysMustRevalidate, isRequireSession, isUseCacheControlHeader, isUseCacheControlNoStore, isUseExpiresHeader, prepareResponse, preventCaching, setAlwaysMustRevalidate, setCacheControl, setCacheSeconds, setRequireSession, setSupportedMethods, setUseCacheControlHeader, setUseCacheControlNoStore, setUseExpiresHeader, setVaryByRequestHeadersMethods inherited from class org.springframework.web.context.support.WebApplicationObjectSupport
getServletContext, getTempDir, getWebApplicationContext, initApplicationContext, initServletContext, isContextRequired, setServletContextMethods inherited from class org.springframework.context.support.ApplicationObjectSupport
getApplicationContext, getMessageSourceAccessor, initApplicationContext, obtainApplicationContext, requiredContextClass, setApplicationContext
-
Constructor Details
-
FlowHandlerAdapter
public FlowHandlerAdapter()Creates a new flow handler adapter.
-
-
Method Details
-
getFlowExecutor
Returns the central service for executing flows. Required. -
setFlowExecutor
Sets the central service for executing flows. Required.- Parameters:
flowExecutor-
-
getFlowUrlHandler
Returns the flow url handler. -
setFlowUrlHandler
Sets the flow url handler- Parameters:
flowUrlHandler- the flow url handler
-
getAjaxHandler
Returns the configured Ajax handler. -
setAjaxHandler
Sets the configured Ajax handler.- Parameters:
ajaxHandler- the ajax handler
-
getRedirectHttp10Compatible
public boolean getRedirectHttp10Compatible()Whether redirect sent by this handler adapter should be compatible with HTTP 1.0 clients.- Returns:
- true if so, false otherwise
-
setRedirectHttp10Compatible
public void setRedirectHttp10Compatible(boolean redirectHttp10Compatible) Set whether redirects sent by this handler adapter should be compatible with HTTP 1.0 clients.By default, this will enforce a redirect HTTP status code of 302 by delegating to
HttpServletResponse.sendRedirect. Setting this to false will send HTTP status code 303, which is the correct code for HTTP 1.1 clients, but not understood by HTTP 1.0 clients.Many HTTP 1.1 clients treat 302 just like 303, not making any difference. However, some clients depend on 303 when redirecting after a POST request; turn this flag off in such a scenario.
- See Also:
-
HttpServletResponse.sendRedirect(java.lang.String)
-
setStatusCode
public void setStatusCode(org.springframework.http.HttpStatus statusCode) Set the status code for this view.Default is to send 302/303, depending on the value of the
http10Compatibleflag. -
setHosts
Configure one or more hosts associated with the application. All other hosts will be considered external hosts. In effect this property provides a way turn off encoding viaHttpServletResponse.encodeRedirectURL(java.lang.String)for URLs that have a host and that host is not listed as a known host.If not set (the default) all URLs are encoded through the response.
- Parameters:
hosts- one or more application hosts- Since:
- 2.4.3
-
getHosts
Return the configured hosts associated with the application. -
setSaveOutputToFlashScopeOnRedirect
public void setSaveOutputToFlashScopeOnRedirect(boolean saveOutputToFlashScopeOnRedirect) Set whether servlet relative redirects sent by this handler adapter should passflow outputto the Spring MVCflash scope.By default, to remain compatible with previous releases, flow output is not mapped to flash scope.
- Parameters:
saveOutputToFlashScopeOnRedirect-
-
getSaveOutputToFlashScopeOnRedirect
public boolean getSaveOutputToFlashScopeOnRedirect()Whether servlet relative redirects should passflow outputto the Spring MVCflash scope.- Returns:
trueif so,falseotherwise
-
afterPropertiesSet
- Specified by:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean- Throws:
Exception
-
supports
- Specified by:
supportsin interfaceorg.springframework.web.servlet.HandlerAdapter
-
handle
public org.springframework.web.servlet.ModelAndView handle(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, Object handler) throws Exception - Specified by:
handlein interfaceorg.springframework.web.servlet.HandlerAdapter- Throws:
Exception
-
getLastModified
- Specified by:
getLastModifiedin interfaceorg.springframework.web.servlet.HandlerAdapter
-
createServletExternalContext
protected ServletExternalContext createServletExternalContext(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) Creates the servlet external context for the current HTTP servlet request.- Parameters:
request- the current requestresponse- the current response
-
defaultGetFlowId
The default algorithm to determine the id of the flow to launch from the current request. Only called ifFlowHandler.getFlowId()returns null. This implementation delegates to the configuredFlowUrlHandler.getFlowId(HttpServletRequest). Subclasses may override.- Parameters:
request- the current request
-
defaultCreateFlowExecutionInputMap
protected MutableAttributeMap<Object> defaultCreateFlowExecutionInputMap(jakarta.servlet.http.HttpServletRequest request) The default algorithm to create the flow execution input map. Only called ifFlowHandler.createExecutionInputMap(HttpServletRequest)returns null. This implementation exposes all current request parameters as flow execution input attributes. Subclasses may override.- Parameters:
request- the current request
-
defaultHandleExecutionOutcome
protected void defaultHandleExecutionOutcome(String flowId, FlowExecutionOutcome outcome, ServletExternalContext context, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) throws IOException The default algorithm for handling a flow execution outcome. Only called ifFlowHandler.handleExecutionOutcome(FlowExecutionOutcome, HttpServletRequest, HttpServletResponse)returns null. This implementation attempts to start a new execution of the ended flow. Any flow execution output is passed as input to the new execution. Subclasses may override.- Parameters:
flowId- the id of the ended flowoutcome- the flow execution outcomecontext- ServletExternalContext the completed ServletExternalContextrequest- the current requestresponse- the current response- Throws:
IOException
-
defaultHandleException
protected void defaultHandleException(String flowId, FlowException e, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) throws IOException The default algorithm for handling aFlowExceptionnow handled by the Web Flow system. Only called ifFlowHandler.handleException(FlowException, HttpServletRequest, HttpServletResponse)returns null. This implementation rethrows the exception unless it is aNoSuchFlowExecutionException. If the exception is a NoSuchFlowExecutionException, this implementation attempts to start a new execution of the ended or expired flow. Subclasses may override.- Parameters:
flowId- the id of the ended flowe- the flow exceptionrequest- the current requestresponse- the current response- Throws:
IOException
-
sendRedirect
protected void sendRedirect(String url, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) throws IOException Sends a redirect to the requested url usingHttpServletResponse.sendRedirect(String).Called to actually perform flow execution redirects, flow definition redirects, and external redirects. Subclasses may override to customize general Web Flow system redirect behavior.- Parameters:
url- the url to redirect torequest- the current requestresponse- the current response- Throws:
IOException- an exception occurred
-
isRemoteHost
Whether the given targetUrl has a host that is a "foreign" system in which caseHttpServletResponse.encodeRedirectURL(java.lang.String)will not be applied. This method returnstrueif thesetHosts(String[])property is configured and the target URL has a host that does not match.- Parameters:
targetUrl- the target redirect URL- Returns:
truethe target URL has a remote host,falseif it the URL does not have a host or the "host" property is not configured.- Since:
- 2.4.3
-