/* Saves the result of the current request on the session, does a 302 redirect into a direct action to clear the browser history. In the handler of redirect request, it returns the page that was saved on the request. */ protected AWResponse clearBrowserHistory( AWRequestContext requestContext, AWComponent actionResultsComponent) { AWPage actionResultsPage = actionResultsComponent.page(); actionResultsPage.ensureAwake(requestContext); // This rewrites the DirectAction request URL into a ComponentAction // request URL in the browser by using a redirect. // Note [sessionless requests]: ordering of condition is important. Let // component declare "non-refresh" (no cache or no redirect) before // attempting to interact with the session -- allows for "sessionless" // direct actions. This is important since we always attempt to // rendevous with the session id now. Fixes race condition at logout // in suite integrated mode. LogoutAck from another app starts processing // before ClientLogout for authenticator is complete. RequestContext for // LogoutAck starts off with a valid sessionid, but by the time it gets // here, the session has been invalidated. LogoutAck needs to be // completely sessionless. if (AWComponentActionRequestHandler.IsFormPostRedirectEnabled && actionResultsComponent.shouldCachePage() && actionResultsComponent.shouldRedirect() && requestContext.session(false) != null && !requestContext.isIncrementalUpdateRequest()) { // This saves the actual page and not the redirect page. When the // redirect fires it will restore the saved page, which should be // treated as a refreshRequest (no applyValues/invokeAction). // associate a response id with the current request for page // history maintenance AWSession session = requestContext.session(); session.incrementResponseId(); AWApplication application = application(); AWRedirect redirectComponent = (AWRedirect) application.createPageWithName(AWRedirect.PageName, requestContext); String effectiveUrl = AWComponentActionRequestHandler.SharedInstance.refreshUrl(requestContext); effectiveUrl = AWUtil.urlAddingQueryValue(effectiveUrl, DirectActionRedirectKey, "1"); redirectComponent.setUrl(effectiveUrl); redirectComponent.setSelfRedirect(true); requestContext.setPage(redirectComponent.page()); actionResultsPage.ensureAsleep(); Log.aribaweb.debug("Sending redirect to clear browser history"); } else { requestContext.setPage(actionResultsPage); } // We need to check for the existence of a session and save the page // before generateResponse in order to maintain uniformity with // AWComponentActionRequestHandler. // Since generateResponse() can cause a new session to be // associated with the request, we need to make sure we try save // the page after generateResponse if the page was not already saved. boolean pageSaved = attemptSavePage(requestContext, actionResultsPage); AWResponse response = requestContext.generateResponse(); if (!pageSaved) { attemptSavePage(requestContext, actionResultsPage); } return response; }