Class FilenameFlowUrlHandler
java.lang.Object
org.springframework.webflow.context.servlet.DefaultFlowUrlHandler
org.springframework.webflow.context.servlet.FilenameFlowUrlHandler
- All Implemented Interfaces:
FlowUrlHandler
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:
https://someHost/someApp/someServlet/foo https://someHost/someApp/someServlet/nestedPath/foo https://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.- Author:
- Agim Emruli, Jeremy Grelle, Nazaret Kazarian
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptioncreateFlowDefinitionUrl
(String flowId, AttributeMap<?> input, jakarta.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.static String
extractFilenameFromUrlPath
(String urlPath) static String
extractFullFilenameFromUrlPath
(String urlPath) getFlowId
(jakarta.servlet.http.HttpServletRequest request) Extract the flow id from the request.Methods inherited from class org.springframework.webflow.context.servlet.DefaultFlowUrlHandler
appendQueryParameters, createFlowExecutionUrl, getEncodingScheme, getFlowExecutionKey, setEncodingScheme
-
Constructor Details
-
FilenameFlowUrlHandler
public FilenameFlowUrlHandler()
-
-
Method Details
-
getFlowId
Description copied from interface:FlowUrlHandler
Extract the flow id from the request.- Specified by:
getFlowId
in interfaceFlowUrlHandler
- Overrides:
getFlowId
in classDefaultFlowUrlHandler
- Parameters:
request
- the request- Returns:
- the flow id, or null if no flow id is present
-
extractFilenameFromUrlPath
-
extractFullFilenameFromUrlPath
-
createFlowDefinitionUrl
public String createFlowDefinitionUrl(String flowId, AttributeMap<?> input, jakarta.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:
https://someHost/someApp/someServlet/nestedPath/foo.html
and a request for the flow id "bar", the new flow definition URL would be:https://someHost/someApp/someServlet/nestedPath/bar.html
- Specified by:
createFlowDefinitionUrl
in interfaceFlowUrlHandler
- Overrides:
createFlowDefinitionUrl
in classDefaultFlowUrlHandler
- Parameters:
flowId
- the id of the flow definitioninput
- the input to pass the new flow executionrequest
- the current request- Returns:
- the flow definition url
-