private void _restoreRedirectValue(FacesContext facesContext)
    {
        ExternalContext externalContext = facesContext.getExternalContext();
        HttpServletResponse httpResponse = ExternalContextUtils
                .getHttpServletResponse(externalContext);
        if (httpResponse != null)
        {
            // Request values are lost after a redirect. We can create a 
            // temporal cookie to pass the params between redirect calls.
            // It is better than use HttpSession object, because this cookie
            // is never sent by the server.
            Cookie cookie = (Cookie) externalContext
                    .getRequestCookieMap().get(FLASH_REDIRECT);
            if (cookie != null)
            {
                // the cookie exists means there was a redirect, regardless of the value
                externalContext.getRequestMap().put(
                        FLASH_PREVIOUS_REQUEST_REDIRECT, Boolean.TRUE);
                
                // A redirect happened, so it is safe to remove the cookie, setting
                // the maxAge to 0 seconds. The effect is we passed FLASH_REDIRECT param 
                // to this request object
                cookie.setMaxAge(0);
                cookie.setPath(_getCookiePath(externalContext));
                //MYFACES-3354 jetty 6.1.5 does not allow this,
                //call setMaxAge(0) is enough
                //cookie.setValue(null);
                httpResponse.addCookie(cookie);
            }
        }
        else
        {
            // Note that on portlet world we can't create cookies,
            // so we are forced to use the session map. Anyway, 
            // according to the Bridge implementation(for example see 
            // org.apache.myfaces.portlet.faces.bridge.BridgeImpl)
            // session object is created at start faces request
            Map<String, Object> sessionMap = externalContext.getSessionMap();
            
            // remove the value from the sessionMap
            Boolean redirect = (Boolean) sessionMap.remove(FLASH_REDIRECT);
            
            // put the value into the requestMap
            externalContext.getRequestMap().put(
                    FLASH_PREVIOUS_REQUEST_REDIRECT, redirect);
        }
    }
private void _restoreRedirectValue ( FacesContext facesContext ) { ExternalContext externalContext = facesContext . getExternalContext ( ) ; HttpServletResponse httpResponse = ExternalContextUtils . getHttpServletResponse ( externalContext ) ; if ( httpResponse != null ) { Cookie cookie = ( Cookie ) externalContext . getRequestCookieMap ( ) . get ( FLASH_REDIRECT ) ; if ( cookie != null ) { externalContext . getRequestMap ( ) . put ( FLASH_PREVIOUS_REQUEST_REDIRECT , Boolean . TRUE ) ; cookie . setMaxAge ( 0 ) ; cookie . setPath ( _getCookiePath ( externalContext ) ) ; httpResponse . addCookie ( cookie ) ; } } else { Map < String , Object > sessionMap = externalContext . getSessionMap ( ) ; Boolean redirect = ( Boolean ) sessionMap . remove ( FLASH_REDIRECT ) ; externalContext . getRequestMap ( ) . put ( FLASH_PREVIOUS_REQUEST_REDIRECT , redirect ) ; } }
Restores the redirect value of the previous request and saves
it in the RequestMap under the key FLASH_PREVIOUS_REQUEST_REDIRECT.
Must not be called more than once per request.
After this method was invoked, the requestMap will contain Boolean.TRUE
if setRedirect(true) was called on the previous request or Boolean.FALSE
or null otherwise.