org.springframework.webflow.executor.support
Class RequestParameterFlowExecutorArgumentHandler

java.lang.Object
  extended by org.springframework.webflow.executor.support.FlowExecutorArgumentHandler
      extended by org.springframework.webflow.executor.support.RequestParameterFlowExecutorArgumentHandler
All Implemented Interfaces:
FlowExecutorArgumentExposer, FlowExecutorArgumentExtractor
Direct Known Subclasses:
RequestPathFlowExecutorArgumentHandler

public class RequestParameterFlowExecutorArgumentHandler
extends FlowExecutorArgumentHandler

Default FlowExecutor argument handler that extracts flow executor method arguments from the ExternalContext.getRequestParameterMap() and exposes arguments as URL encoded request parameters.

Author:
Keith Donald, Erwin Vervaet

Constructor Summary
RequestParameterFlowExecutorArgumentHandler()
           
 
Method Summary
protected  void appendFlowExecutorPath(java.lang.StringBuffer url, ExternalContext context)
          Append the URL path to the flow executor capable of accepting new requests.
protected  void appendQueryParameter(java.lang.StringBuffer url, java.lang.Object key, java.lang.Object value)
          Appends a single query parameter to a URL.
protected  void appendQueryParameters(java.lang.StringBuffer url, java.util.Map parameters)
          Append query parameters to the redirect URL.
 java.lang.String createExternalUrl(ExternalRedirect redirect, java.lang.String flowExecutionKey, ExternalContext context)
          Create a URL path that when redirected to communicates with an external system outside of Spring Web Flow.
 java.lang.String createFlowDefinitionUrl(FlowDefinitionRedirect flowDefinitionRedirect, ExternalContext context)
          Create a URL that when redirected to launches a entirely new execution of a flow definition (starts a new conversation).
 java.lang.String createFlowExecutionUrl(java.lang.String flowExecutionKey, FlowExecutionContext flowExecution, ExternalContext context)
          Create a URL path that when redirected to renders the current (or last) view selection made by the flow execution identified by the flow execution key.
 java.lang.String extractEventId(ExternalContext context)
          Extract the flow execution event id from the external context.
 java.lang.String extractFlowExecutionKey(ExternalContext context)
          Extract the flow execution key from the external context.
 java.lang.String extractFlowId(ExternalContext context)
          Extracts the flow id from the external context.
protected  java.lang.String findParameter(java.lang.String logicalParameterName, ParameterMap parameters)
          Obtain a named parameter from the request parameters.
 java.lang.String getParameterValueDelimiter()
          Returns the delimiter used to parse a parameter value when a value is embedded in a parameter name (e.g.
 boolean isEventIdPresent(ExternalContext context)
          Returns true if the event id is extractable from the context.
 boolean isFlowExecutionKeyPresent(ExternalContext context)
          Returns true if the flow execution key is extractable from the context.
 boolean isFlowIdPresent(ExternalContext context)
          Returns true if the flow id is extractable from the context.
 void setParameterValueDelimiter(java.lang.String parameterValueDelimiter)
          Set the delimiter used to parse a parameter value when a value is embedded in a parameter name (e.g.
 
Methods inherited from class org.springframework.webflow.executor.support.FlowExecutorArgumentHandler
applyDefaultFlowId, encodeValue, exposeFlowExecutionContext, getDefaultFlowId, getEventIdArgumentName, getFlowExecutionContextAttributeName, getFlowExecutionKeyArgumentName, getFlowExecutionKeyAttributeName, getFlowIdArgumentName, getUrlEncodingScheme, isRedirectContextRelative, makeRedirectUrlContextRelativeIfNecessary, setDefaultFlowId, setEventIdArgumentName, setFlowExecutionContextAttributeName, setFlowExecutionKeyArgumentName, setFlowExecutionKeyAttributeName, setFlowIdArgumentName, setRedirectContextRelative, setUrlEncodingScheme
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RequestParameterFlowExecutorArgumentHandler

public RequestParameterFlowExecutorArgumentHandler()
Method Detail

getParameterValueDelimiter

public java.lang.String getParameterValueDelimiter()
Returns the delimiter used to parse a parameter value when a value is embedded in a parameter name (e.g. "_eventId_submit"). Defaults to "_".


setParameterValueDelimiter

public void setParameterValueDelimiter(java.lang.String parameterValueDelimiter)
Set the delimiter used to parse a parameter value when a value is embedded in a parameter name (e.g. "_eventId_submit").


isFlowIdPresent

public boolean isFlowIdPresent(ExternalContext context)
Description copied from interface: FlowExecutorArgumentExtractor
Returns true if the flow id is extractable from the context.

Specified by:
isFlowIdPresent in interface FlowExecutorArgumentExtractor
Specified by:
isFlowIdPresent in class FlowExecutorArgumentHandler
Parameters:
context - the context in which a external user event occured
Returns:
true if extractable, false if not

extractFlowId

public java.lang.String extractFlowId(ExternalContext context)
                               throws FlowExecutorArgumentExtractionException
Description copied from interface: FlowExecutorArgumentExtractor
Extracts the flow id from the external context.

Specified by:
extractFlowId in interface FlowExecutorArgumentExtractor
Specified by:
extractFlowId in class FlowExecutorArgumentHandler
Parameters:
context - the context in which a external user event occured
Returns:
the extracted flow id
Throws:
FlowExecutorArgumentExtractionException - if the flow id could not be extracted

isFlowExecutionKeyPresent

public boolean isFlowExecutionKeyPresent(ExternalContext context)
Description copied from interface: FlowExecutorArgumentExtractor
Returns true if the flow execution key is extractable from the context.

Specified by:
isFlowExecutionKeyPresent in interface FlowExecutorArgumentExtractor
Specified by:
isFlowExecutionKeyPresent in class FlowExecutorArgumentHandler
Parameters:
context - the context in which a external user event occured
Returns:
true if extractable, false if not

extractFlowExecutionKey

public java.lang.String extractFlowExecutionKey(ExternalContext context)
                                         throws FlowExecutorArgumentExtractionException
Description copied from interface: FlowExecutorArgumentExtractor
Extract the flow execution key from the external context.

Specified by:
extractFlowExecutionKey in interface FlowExecutorArgumentExtractor
Specified by:
extractFlowExecutionKey in class FlowExecutorArgumentHandler
Parameters:
context - the context in which the external user event occured
Returns:
the obtained flow execution key
Throws:
FlowExecutorArgumentExtractionException - if the flow execution key could not be extracted

isEventIdPresent

public boolean isEventIdPresent(ExternalContext context)
Description copied from interface: FlowExecutorArgumentExtractor
Returns true if the event id is extractable from the context.

Specified by:
isEventIdPresent in interface FlowExecutorArgumentExtractor
Specified by:
isEventIdPresent in class FlowExecutorArgumentHandler
Parameters:
context - the context in which a external user event occured
Returns:
true if extractable, false if not

extractEventId

public java.lang.String extractEventId(ExternalContext context)
                                throws FlowExecutorArgumentExtractionException
Description copied from interface: FlowExecutorArgumentExtractor
Extract the flow execution event id from the external context.

This method should only be called if a FlowExecutionKey was successfully extracted, indicating a request to resume a flow execution.

Specified by:
extractEventId in interface FlowExecutorArgumentExtractor
Specified by:
extractEventId in class FlowExecutorArgumentHandler
Parameters:
context - the context in which a external user event occured
Returns:
the event id
Throws:
FlowExecutorArgumentExtractionException - if the event id could not be extracted

findParameter

protected java.lang.String findParameter(java.lang.String logicalParameterName,
                                         ParameterMap parameters)
Obtain a named parameter from the request parameters. This method will try to obtain a parameter value using the following algorithm:
  1. Try to get the parameter value using just the given logical name. This handles parameters of the form logicalName = value. For normal parameters, e.g. submitted using a hidden HTML form field, this will return the requested value.
  2. Try to obtain the parameter value from the parameter name, where the parameter name in the request is of the form logicalName_value = xyz with "_" being the configured delimiter. This deals with parameter values submitted using an HTML form submit button.
  3. If the value obtained in the previous step has a ".x" or ".y" suffix, remove that. This handles cases where the value was submitted using an HTML form image button. In this case the parameter in the request would actually be of the form logicalName_value.x = 123.

Parameters:
logicalParameterName - the logical name of the request parameter
parameters - the available parameter map
Returns:
the value of the parameter, or null if the parameter does not exist in given request

createFlowDefinitionUrl

public java.lang.String createFlowDefinitionUrl(FlowDefinitionRedirect flowDefinitionRedirect,
                                                ExternalContext context)
Description copied from interface: FlowExecutorArgumentExposer
Create a URL that when redirected to launches a entirely new execution of a flow definition (starts a new conversation). Used to support the restart flow and redirect to flow use cases.

Specified by:
createFlowDefinitionUrl in interface FlowExecutorArgumentExposer
Specified by:
createFlowDefinitionUrl in class FlowExecutorArgumentHandler
Parameters:
flowDefinitionRedirect - the flow definition redirect view selection
context - the external context
Returns:
the relative flow URL path to redirect to

createFlowExecutionUrl

public java.lang.String createFlowExecutionUrl(java.lang.String flowExecutionKey,
                                               FlowExecutionContext flowExecution,
                                               ExternalContext context)
Description copied from interface: FlowExecutorArgumentExposer
Create a URL path that when redirected to renders the current (or last) view selection made by the flow execution identified by the flow execution key. Used to support the flow execution redirect use case.

Specified by:
createFlowExecutionUrl in interface FlowExecutorArgumentExposer
Specified by:
createFlowExecutionUrl in class FlowExecutorArgumentHandler
Parameters:
flowExecutionKey - the flow execution key
flowExecution - the flow execution
context - the external context
Returns:
the relative conversation URL path
See Also:
FlowExecutionRedirect

createExternalUrl

public java.lang.String createExternalUrl(ExternalRedirect redirect,
                                          java.lang.String flowExecutionKey,
                                          ExternalContext context)
Description copied from interface: FlowExecutorArgumentExposer
Create a URL path that when redirected to communicates with an external system outside of Spring Web Flow.

Specified by:
createExternalUrl in interface FlowExecutorArgumentExposer
Specified by:
createExternalUrl in class FlowExecutorArgumentHandler
Parameters:
redirect - the external redirect request
flowExecutionKey - the flow execution key to send through the redirect (optional)
context - the external context
Returns:
the external URL

appendFlowExecutorPath

protected void appendFlowExecutorPath(java.lang.StringBuffer url,
                                      ExternalContext context)
Append the URL path to the flow executor capable of accepting new requests.

Parameters:
url - the url buffer to append to
context - the context of this request

appendQueryParameters

protected void appendQueryParameters(java.lang.StringBuffer url,
                                     java.util.Map parameters)
Append query parameters to the redirect URL. Stringifies, URL-encodes and formats model attributes as query parameters.

Parameters:
url - the StringBuffer to append the parameters to
parameters - Map that contains attributes

appendQueryParameter

protected void appendQueryParameter(java.lang.StringBuffer url,
                                    java.lang.Object key,
                                    java.lang.Object value)
Appends a single query parameter to a URL.

Parameters:
url - the target url to append to
key - the parameter name
value - the parameter value


Copyright © 2009 Spring Framework. All Rights Reserved.