Announcement Announcement Module
No announcement yet.
Return to referrer on flow exit? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Return to referrer on flow exit?

    When my flow exits, I'd like it to return back to the page that contained the link that started the flow. If I weren't using WebFlow I'd go about this by recording the referer URL of the initial request that starts the process (and then redirect to that url upon exit).

    Is there a way to grab the referer URL when the flow is initialized? I've looked through RequestContext and it doesn't look like I can get access to HttpRequest header values.

    Is there some other approach that might work?

  • #2
    Using subflows is one option. In that case everything is automatic.

    You could use a FlowVariable or a flow start action to capture the 'referer URL' and store it in flow scope. Then just "externalRedirect:${flowScope.refererUrl}" back to the referer when the flow ends.

    You can get to the actual HttpServletRequest from the RequestContext by downcasting the ExternalContext to ServletExternalContext.



    • #3
      I am attempting to do this same by storing the referer URL in request scope. I am using the flow execution adapter to do this using the requestSubmitted method. However, I am receiving a NoMatchingTransitionException when the flow execution matches the transition that will redirect. I will include my flow configuration in the post for reference.

      From parent flow xml:

      <subflow-state id="userPrefsView" flow="userpreferences-flow">
      <mapping source="${}" target="previousState"/>
      <transition to="${flowScope.lastViewStateId}" on="finish"/>

      <transition on="userPrefs" to="userPrefsView">
      <set attribute="lastViewStateId" value="${}" scope="flow"/>

      From user prefs flow xml:

      <view-state id="userPrefs" view="userPreferences">
      <action bean="userPreferencesAction" method="setupForm"/>
      <action bean="userChangePasswordAction" method="setupForm"/>
      <transition to="actionChangePassword" on="changePassword">
      <action bean="userChangePasswordAction" method="bindAndValidate"/>
      <transition on="cancel" to="decide"/>
      <transition on="save" to="decide"/>

      <decision-state id="decide">
      <if test="${requestScope.returnURL != null}" then="return"/>
      <if test="${flowScope.previousState == null}" then="home" else="finish"/>

      <end-state id="return" view="externalRedirect:${requestScope.returnURL}"/>

      <end-state id="home" view="externalRedirect:index.emvc"/>

      <end-state id="finish"/>
      Last edited by Wayne; May 10th, 2007, 02:02 PM.


      • #4
        I'm not sure requestScope is the right place for this, since it could've been lost by the time you need the value. Check this tip for details:

        Maybe you're seeing a alwaysRedirectOnPause side-effect?