Spring Web Flow

org.springframework.webflow.context.servlet
Class DefaultFlowUrlHandler

java.lang.Object
  extended by org.springframework.webflow.context.servlet.DefaultFlowUrlHandler
All Implemented Interfaces:
FlowUrlHandler
Direct Known Subclasses:
FilenameFlowUrlHandler

public class DefaultFlowUrlHandler
extends java.lang.Object
implements FlowUrlHandler

The default FlowUrlHandler implementation for Spring Web Flow.

Expects URLs to launch flow to be of this pattern:

 http://<host>/[app context path]/[app servlet path]/<flow path>
 
As an example, the URL http://localhost/springtravel/app/booking would map to flow "booking", while the URL http://localhost/springtravel/app/hotels/booking would map to flow "hotels/booking". In both these examples, /springtravel is the context path and /app is the servlet path. The flow id is treated as the path info component of the request URL string. If the path info is null, the servletPath will be used as the flow id. Also, if the servlet path ends in an extension it will be stripped when calculating the flow id. For example, a URL of http://localhost/springtravel/hotels/booking.htm would still map to flow id "hotels/booking", assuming a context path of /springtravel, a servlet path of /hotels/booking.htm (likely mapped with a servlet-mapping of *.htm), and a path info of null.

Expects URLs to resume flows to be of this pattern:

 http://<host>/[app context path]/[app servlet path]/<flow path>?execution=<flow execution key>
 
As an example, the URL http://localhost/springtravel/app/hotels/booking?execution=e1s1 would attempt to resume execution "e1s1" of the "hotels/booking" flow.

Author:
Keith Donald, Jeremy Grelle

Constructor Summary
DefaultFlowUrlHandler()
           
 
Method Summary
protected
<T> void
appendQueryParameters(java.lang.StringBuilder url, java.util.Map<java.lang.String,T> parameters, java.lang.String encodingScheme)
           
 java.lang.String createFlowDefinitionUrl(java.lang.String flowId, AttributeMap<?> input, javax.servlet.http.HttpServletRequest request)
          The flow definition URL for the given flow id will be built by appending the flow id to the base app context and servlet paths.
 java.lang.String createFlowExecutionUrl(java.lang.String flowId, java.lang.String flowExecutionKey, javax.servlet.http.HttpServletRequest request)
          Create a URL that when addressed will resume an existing execution of a flow.
protected  java.lang.String getEncodingScheme(javax.servlet.http.HttpServletRequest request)
           
 java.lang.String getFlowExecutionKey(javax.servlet.http.HttpServletRequest request)
          Extract the flow execution from the request.
 java.lang.String getFlowId(javax.servlet.http.HttpServletRequest request)
          Extract the flow id from the request.
 void setEncodingScheme(java.lang.String encodingScheme)
          Set the character encoding scheme for flow urls.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultFlowUrlHandler

public DefaultFlowUrlHandler()
Method Detail

setEncodingScheme

public void setEncodingScheme(java.lang.String encodingScheme)
Set the character encoding scheme for flow urls. Default is the request's encoding scheme (which is ISO-8859-1 if not specified otherwise).


getFlowExecutionKey

public java.lang.String getFlowExecutionKey(javax.servlet.http.HttpServletRequest request)
Description copied from interface: FlowUrlHandler
Extract the flow execution from the request.

Specified by:
getFlowExecutionKey in interface FlowUrlHandler
Parameters:
request - the request
Returns:
the flow execution key, or null if no flow execution key is present

getFlowId

public java.lang.String getFlowId(javax.servlet.http.HttpServletRequest request)
Description copied from interface: FlowUrlHandler
Extract the flow id from the request.

Specified by:
getFlowId in interface FlowUrlHandler
Parameters:
request - the request
Returns:
the flow id, or null if no flow id is present

createFlowExecutionUrl

public java.lang.String createFlowExecutionUrl(java.lang.String flowId,
                                               java.lang.String flowExecutionKey,
                                               javax.servlet.http.HttpServletRequest request)
Description copied from interface: FlowUrlHandler
Create a URL that when addressed will resume an existing execution of a flow.

Specified by:
createFlowExecutionUrl in interface FlowUrlHandler
flowExecutionKey - the flow execution key that is paused and waiting to be resumed
request - the current request
Returns:
the flow execution url

createFlowDefinitionUrl

public java.lang.String createFlowDefinitionUrl(java.lang.String flowId,
                                                AttributeMap<?> input,
                                                javax.servlet.http.HttpServletRequest request)
The flow definition URL for the given flow id will be built by appending the flow id to the base app context and servlet paths.

Example - given a request originating at:

 http://someHost/someApp/someServlet/nestedPath/foo
 
and a request for the flow id "nestedPath/bar", the new flow definition URL would be:
 http://someHost/someApp/someServlet/nestedPath/bar
 

Specified by:
createFlowDefinitionUrl in interface FlowUrlHandler
Parameters:
flowId - the id of the flow definition
input - the input to pass the new flow execution
request - the current request
Returns:
the flow definition url

getEncodingScheme

protected java.lang.String getEncodingScheme(javax.servlet.http.HttpServletRequest request)

appendQueryParameters

protected <T> void appendQueryParameters(java.lang.StringBuilder url,
                                         java.util.Map<java.lang.String,T> parameters,
                                         java.lang.String encodingScheme)

Spring Web Flow