org.szegedi.spring.web.jsflow
Class UrlScriptSelectionStrategy

java.lang.Object
  extended by org.szegedi.spring.web.jsflow.UrlScriptSelectionStrategy
All Implemented Interfaces:
ScriptSelectionStrategy

public class UrlScriptSelectionStrategy
extends java.lang.Object
implements ScriptSelectionStrategy

A script selection strategy that uses the components of the request URL to select a script to run.

Version:
$Id: $
Author:
Attila Szegedi

Constructor Summary
UrlScriptSelectionStrategy()
           
 
Method Summary
 java.lang.String getScriptPath(javax.servlet.http.HttpServletRequest request)
          Returns the pathname of the script that should run for a particular initial HTTP request.
 void setResourcePath(java.lang.String resourcePath)
          Sets the resource path.
 void setUsePathInfo(boolean usePathInfo)
          Whether to use the path info portion of the request URI when selecting a script to run.
 void setUseServletPath(boolean useServletPath)
          Whether to use the servlet path portion of the request URI when looking up the script to run.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UrlScriptSelectionStrategy

public UrlScriptSelectionStrategy()
Method Detail

setResourcePath

public void setResourcePath(java.lang.String resourcePath)
Sets the resource path. If neither path info nor servlet path are used, then this strategy will always select a single script, the resource path of its source file being specified in this property. If either servlet path or path info (or both) are used, then the strategy will select multiple scripts selected by servlet path and/or path info, and the path specified here will be used as a common prefix for the resource paths of script source files. Defaults to empty string, which is a handy value in case no prefix is required and either servlet path or path info are used. Be aware that this prefix can be further prefixed by a prefix specified using ScriptStorage.setPrefix(String)) ScriptStorage class.

Parameters:
resourcePath -

setUsePathInfo

public void setUsePathInfo(boolean usePathInfo)
Whether to use the path info portion of the request URI when selecting a script to run. If true, the name of the script to run will be determined by concatenating resource path + (optionally servlet path) + path info. If false, the name of the selected script will be determined by concatenating resource path + (optionally servlet path). Defaults to false.

Parameters:
usePathInfo -

setUseServletPath

public void setUseServletPath(boolean useServletPath)
Whether to use the servlet path portion of the request URI when looking up the script to run. If true, the name of the script to run will be determined by concatenating resource path + servlet path + (optionally path info). If false, the name of the script to run will be determined by concatenating resource path + (optionally path info). Defaults to false.

Parameters:
useServletPath -

getScriptPath

public java.lang.String getScriptPath(javax.servlet.http.HttpServletRequest request)
Description copied from interface: ScriptSelectionStrategy
Returns the pathname of the script that should run for a particular initial HTTP request.

Specified by:
getScriptPath in interface ScriptSelectionStrategy
Parameters:
request - the HTTP request that initiates a flow
Returns:
the path of the script. null can be returned to indicate that this strategy is unable to select a script (i.e. because some data is missing in the request). The controller will respond to this by sending back a HTTP 400 "Bad Request" status. Alternatively, the strategy can throw an instance of Spring's ModelAndViewDefiningException to indicate failure.