Announcement Announcement Module
Collapse
No announcement yet.
Return to referrer on flow exit? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • 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.

    Erwin

    Comment


    • #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">
      <attribute-mapper>
      <input-mapper>
      <mapping source="${currentState.id}" target="previousState"/>
      </input-mapper>
      </attribute-mapper>
      <transition to="${flowScope.lastViewStateId}" on="finish"/>
      </subflow-state>

      <global-transitions>
      <transition on="userPrefs" to="userPrefsView">
      <set attribute="lastViewStateId" value="${currentState.id}" scope="flow"/>
      </transition>
      </global-transitions>

      From user prefs flow xml:

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

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

      <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.

      Comment


      • #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:
        http://www.ervacon.com/products/swf/tips/tip4.html

        Maybe you're seeing a alwaysRedirectOnPause side-effect?

        Erwin

        Comment

        Working...
        X