Class FilenameFlowUrlHandler

java.lang.Object
org.springframework.webflow.context.servlet.DefaultFlowUrlHandler
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:

        https://someHost/someApp/someServlet/foo
        https://someHost/someApp/someServlet/nestedPath/foo
        https://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 Details

    • FilenameFlowUrlHandler

      public FilenameFlowUrlHandler()
  • Method Details

    • getFlowId

      public String getFlowId(jakarta.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
    • extractFilenameFromUrlPath

      public static String extractFilenameFromUrlPath(String urlPath)
    • extractFullFilenameFromUrlPath

      public static String extractFullFilenameFromUrlPath(String urlPath)
    • 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 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