org.springframework.webflow.context.servlet
Class FilenameFlowUrlHandler

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

public class FilenameFlowUrlHandler
extends DefaultFlowUrlHandler

A file name based FlowUrlHandler implementation that is an alternative to the standard DefaultFlowUrlHandler. Treats the filename of a request without the URL suffix and/or prefix as the flow id. Used by the FlowController implementation as a default implementation to preserve compatibility with existing Web Flow 2 applications.

This implementation extracts the filename and removes the file extension from the request URL. The results will be used as the flow Id that must be unique throughout the application. For example the URLs

        http://someHost/someApp/someServlet/foo
        http://someHost/someApp/someServlet/nestedPath/foo
        http://someHost/someApp/someServlet/nestedPath/foo.html
 
will all treat the filename "foo" as the flow id.

Note: Because this class only treats a filename as a flow id, clashes can result. For example:
 http://localhost/springtravel/app/hotel/booking
 http://localhost/springtravel/app/flight/booking
 
would both map the same flow id "booking", instead of "hotel/booking" and "flight/booking". This is an limitation of this implementation. Consider using the standard DefaultFlowUrlHandler that uses the request URL prefix as well to avoid these clashes.

Author:
Agim Emruli, Jeremy Grelle, Nazaret Kazarian

Constructor Summary
FilenameFlowUrlHandler()
           
 
Method Summary
 String createFlowDefinitionUrl(String flowId, AttributeMap input, javax.servlet.http.HttpServletRequest request)
          The flow definition URL for the given flowId will be inferred from the URL of the current request, re-using the same path and file extension.
 String getFlowId(javax.servlet.http.HttpServletRequest request)
          Extract the flow id from the request.
 
Methods inherited from class org.springframework.webflow.context.servlet.DefaultFlowUrlHandler
createFlowExecutionUrl, getFlowExecutionKey, setEncodingScheme
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FilenameFlowUrlHandler

public FilenameFlowUrlHandler()
Method Detail

getFlowId

public 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
Overrides:
getFlowId in class DefaultFlowUrlHandler
Parameters:
request - the request
Returns:
the flow id, or null if no flow id is present

createFlowDefinitionUrl

public String createFlowDefinitionUrl(String flowId,
                                      AttributeMap input,
                                      javax.servlet.http.HttpServletRequest request)
The flow definition URL for the given flowId will be inferred from the URL of the current request, re-using the same path and file extension.

Example - given a request originating at:

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

Specified by:
createFlowDefinitionUrl in interface FlowUrlHandler
Overrides:
createFlowDefinitionUrl in class DefaultFlowUrlHandler
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