public class FilenameFlowUrlHandler extends DefaultFlowUrlHandler
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.htmlwill 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/bookingwould 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.Constructor and Description |
---|
FilenameFlowUrlHandler() |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
createFlowDefinitionUrl(java.lang.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.
|
java.lang.String |
getFlowId(javax.servlet.http.HttpServletRequest request)
Extract the flow id from the request.
|
appendQueryParameters, createFlowExecutionUrl, getEncodingScheme, getFlowExecutionKey, setEncodingScheme
public java.lang.String getFlowId(javax.servlet.http.HttpServletRequest request)
FlowUrlHandler
getFlowId
in interface FlowUrlHandler
getFlowId
in class DefaultFlowUrlHandler
request
- the requestpublic java.lang.String createFlowDefinitionUrl(java.lang.String flowId, AttributeMap<?> input, javax.servlet.http.HttpServletRequest request)
Example - given a request originating at:
http://someHost/someApp/someServlet/nestedPath/foo.htmland a request for the flow id "bar", the new flow definition URL would be:
http://someHost/someApp/someServlet/nestedPath/bar.html
createFlowDefinitionUrl
in interface FlowUrlHandler
createFlowDefinitionUrl
in class DefaultFlowUrlHandler
flowId
- the id of the flow definitioninput
- the input to pass the new flow executionrequest
- the current request