public ActionForward doReturnToPage( FlowControllerHandlerContext context, PreviousPageInfo prevPageInfo,
                                         PageFlowController currentPageFlow, ActionForm currentForm,
                                         String actionName, Forward pageFlowFwd )
    {
        assert context.getRequest() instanceof HttpServletRequest : "don't support ServletRequest currently.";
        HttpServletRequest request = ( HttpServletRequest ) context.getRequest();
        
        if ( prevPageInfo == null )
        {
            if ( _log.isInfoEnabled() )
            {
                _log.info( "Attempted return-to-page, but previous page info was missing." );
            }
        
            PageFlowException ex = new NoPreviousPageException( actionName, pageFlowFwd, currentPageFlow );
            InternalUtils.throwPageFlowException( ex, request );
        }
        
        //
        // Figure out what URI to return to, and set the original form in the request or session.
        //        
        ActionForward retFwd = prevPageInfo.getForward();
        ActionMapping prevMapping = prevPageInfo.getMapping();
        
        //
        // Restore any forms that are specified by this Forward (overwrite the original forms).
        //
        if ( retFwd instanceof Forward )
        {
            PageFlowUtils.setOutputForms( prevMapping, ( Forward ) retFwd, request, false );
            InternalUtils.addActionOutputs( ( ( Forward ) retFwd ).getActionOutputs(), request, false );
        }
        
        //
        // If the user hit the previous page directly (without going through an action), prevMapping will be null.
        //
        if ( prevMapping != null )
        {
            //
            // If the currently-posted form is of the right type, initialize the page with that (but we don't overwrite
            // the form that was set above).
            //
            if ( currentForm != null ) PageFlowUtils.setOutputForm( prevMapping, currentForm, request, false );
        
            //
            // Initialize the page with the original form it got forwarded (but we don't overwrite the form that was
            // set above).
            //
            InternalUtils.setFormInScope( prevMapping.getName(), prevPageInfo.getForm(), prevMapping, request, false );
        }
            
        //
        // If we're forwarding to a page in a different pageflow, we need to make sure the returned ActionForward has
        // the right module path, and that it has contextRelative=true.
        //
        FlowController flowController = context.getFlowController();
        
        if ( ! retFwd.getContextRelative() && flowController != currentPageFlow )
        {

            retFwd = new ActionForward( retFwd.getName(),
                                        currentPageFlow.getModulePath() + retFwd.getPath(),
                                        retFwd.getRedirect(),
                                        true );

        }
        
        if ( _log.isDebugEnabled() )
        {
            _log.debug( "Return-to-page in PageFlowController " + flowController.getClass().getName()
                       + ": original URI " + retFwd.getPath() );
        }
        
        if ( retFwd != null )
        {
            //
            // If the new (return-to) Forward specifies a redirect value explicitly, use that; otherwise
            // use the redirect value from the original Forward.
            //
            if ( pageFlowFwd.hasExplicitRedirectValue() ) retFwd.setRedirect( pageFlowFwd.getRedirect() );
            
            //
            // If there's a query string, override the previous query string.
            //
            String fwdPath = retFwd.getPath();
            String newQueryString = pageFlowFwd.getQueryString();
            int existingQueryPos = fwdPath.indexOf( '?' );
            
            //
            // If the new Forward (the one with Jpf.NavigateTo.currentPage/previousPage) has a query string, use that.
            // Otherwise, if the old Forward has no query string, restore the one from the PreviousPageInfo if
            // appropriate.
            //
            if ( newQueryString != null )
            {
                // Chop off the old query string if necessary.
                if ( existingQueryPos != -1 ) fwdPath = fwdPath.substring( 0, existingQueryPos );
                retFwd.setPath( fwdPath + newQueryString );
            }
            else if ( existingQueryPos == -1 )
            {
                retFwd.setPath( fwdPath + getQueryString( pageFlowFwd, prevPageInfo ) );
            }
        }
        
        PageFlowRequestWrapper.get( request ).setPreviousPageInfo( prevPageInfo );
        return retFwd;
    }
public ActionForward doReturnToPage ( FlowControllerHandlerContext context , PreviousPageInfo prevPageInfo , PageFlowController currentPageFlow , ActionForm currentForm , String actionName , Forward pageFlowFwd ) { assert context . getRequest ( ) instanceof HttpServletRequest : "don't support ServletRequest currently." ; HttpServletRequest request = ( HttpServletRequest ) context . getRequest ( ) ; if ( prevPageInfo == null ) { if ( _log . isInfoEnabled ( ) ) { _log . info ( "Attempted return-to-page, but previous page info was missing." ) ; } PageFlowException ex = new NoPreviousPageException ( actionName , pageFlowFwd , currentPageFlow ) ; InternalUtils . throwPageFlowException ( ex , request ) ; } ActionForward retFwd = prevPageInfo . getForward ( ) ; ActionMapping prevMapping = prevPageInfo . getMapping ( ) ; if ( retFwd instanceof Forward ) { PageFlowUtils . setOutputForms ( prevMapping , ( Forward ) retFwd , request , false ) ; InternalUtils . addActionOutputs ( ( ( Forward ) retFwd ) . getActionOutputs ( ) , request , false ) ; } if ( prevMapping != null ) { if ( currentForm != null ) PageFlowUtils . setOutputForm ( prevMapping , currentForm , request , false ) ; InternalUtils . setFormInScope ( prevMapping . getName ( ) , prevPageInfo . getForm ( ) , prevMapping , request , false ) ; } FlowController flowController = context . getFlowController ( ) ; if ( ! retFwd . getContextRelative ( ) && flowController != currentPageFlow ) { retFwd = new ActionForward ( retFwd . getName ( ) , currentPageFlow . getModulePath ( ) + retFwd . getPath ( ) , retFwd . getRedirect ( ) , true ) ; } if ( _log . isDebugEnabled ( ) ) { _log . debug ( "Return-to-page in PageFlowController " + flowController . getClass ( ) . getName ( ) + ": original URI " + retFwd . getPath ( ) ) ; } if ( retFwd != null ) { if ( pageFlowFwd . hasExplicitRedirectValue ( ) ) retFwd . setRedirect ( pageFlowFwd . getRedirect ( ) ) ; String fwdPath = retFwd . getPath ( ) ; String newQueryString = pageFlowFwd . getQueryString ( ) ; int existingQueryPos = fwdPath . indexOf ( '?' ) ; if ( newQueryString != null ) { if ( existingQueryPos != - 1 ) fwdPath = fwdPath . substring ( 0 , existingQueryPos ) ; retFwd . setPath ( fwdPath + newQueryString ) ; } else if ( existingQueryPos == - 1 ) { retFwd . setPath ( fwdPath + getQueryString ( pageFlowFwd , prevPageInfo ) ) ; } } PageFlowRequestWrapper . get ( request ) . setPreviousPageInfo ( prevPageInfo ) ; return retFwd ; }
Get an ActionForward to the original page that was visible before the previous action.