}
if (currentPage.pageComponent().shouldValidateRequest()) {
currentPage.pageComponent().validateRequest(requestContext);
}
if (! isValidNode(requestContext)) {
throw new AWGenericException("Security Exception. Invalid node.");
}
int requestType = session.requestType(request);
AWPage perfSourcePage = null;
String perfSourceArea = null;
switch (requestType) {
case AWSession.BacktrackRequest:
case AWSession.ForwardTrackRequest: {
currentPage.ensureAwake(requestContext);
AWPage restoredPage = null;
AWBacktrackState backtrackState =
(requestType == AWSession.BacktrackRequest) ?
currentPage.updateBacktrackStateForBackButton() :
currentPage.updateBacktrackStateForForwardButton();
// record perf trace info
perfSourcePage = currentPage;
perfSourceArea = (requestType == AWSession.BacktrackRequest)
? "backtrack" : "forwardtrack";
if (backtrackState != null) {
requestContext.setBacktrackState(backtrackState);
restoredPage = currentPage;
}
else {
restoredPage = (requestType == AWSession.BacktrackRequest) ?
session.restorePreviousPage(currentPage) :
session.restoreNextPage(currentPage);
restoredPage.ensureAwake(requestContext);
}
session.savePage(restoredPage);
requestContext.setPage(restoredPage);
response = requestContext.generateResponse();
break;
}
case AWSession.InterruptedNewRequest:
// this is the case where a request came in from an obsolete page (e.g. the user pushed another
// button while the previous action was still running. We treat this like a refresh and take
// them to the "currentPage" -- i.e. the one that was the result of the *first* action.
case AWSession.RefreshRequest: {
// record perf trace info
perfSourcePage = currentPage;
perfSourceArea = "refresh";
// if the current page is a boundary (ie AWRedirect), then
// move the server state back one, allowing us to skip over the
// boundary page -- note that this may be a refresh request due to a
// browser backtrack (since boundary components should not be refreshable)
if (currentPage.pageComponent().isBoundary()) {
// check to see there is a previous page in the page cache, if
// so, then do a server side back. If not, then do a browser
// backtrack. For the case that there is a boundary page as the
// first (and only) page on the page cache (DashboardMain).
if (session.previousPage(currentPage) != null) {
requestContext.setHistoryAction(AWSession.BacktrackRequest);
session.initRequestType();
currentPage = session.restorePreviousPage(currentPage);
}
else {
// no previous page so return the browser back here ...
response = application.createResponse();
AWRedirect.browserBack(response);
}
// record perf trace info
perfSourcePage = currentPage;
perfSourceArea = "backtrack";
}
if (response == null) {
// AWReload support
if (AWConcreteApplication.IsRapidTurnaroundEnabled) AWUtil.getClassLoader().checkForUpdates();
currentPage.ensureAwake(requestContext);
session.savePage(currentPage);
requestContext.setPage(currentPage);
response = requestContext.generateResponse();
}
break;
}
case AWSession.NewRequest: {
currentPage.ensureAwake(requestContext);
AWResponseGenerating actionResults = null;
if (isInterrupted) {
actionResults = currentPage.pageComponent();
}
else {
requestContext.applyValues();
actionResults = requestContext.invokeActionForRequest();
if (actionResults == null) {
if (false && AWConcreteApplication.IsDebuggingEnabled) {
Assert.that(false,
"Unable to locate item which was clicked. Target senderId: %s",
requestContext.requestSenderId());
}
else {
actionResults = currentPage.pageComponent();
}
}
}
// Allow response to replace itself (see AWRedirect for example)
if (actionResults instanceof AWResponseGenerating.ResponseSubstitution) {
actionResults = ((AWResponseGenerating.ResponseSubstitution)actionResults).replacementResponse();
}
if (actionResults instanceof AWComponent) {
AWComponent actionResultsComponent = (AWComponent)actionResults;
AWPage actionResultsPage = actionResultsComponent.page();
if (actionResultsPage != currentPage) {
// check if user is allowed to see this page
// If not, record it before propagating exception so that post
// auth they proceed to new page
if (actionResultsComponent.shouldValidateSession()) {
try {
actionResultsComponent.validateSession(requestContext);
}
catch (AWSessionValidationException e) {
session.savePage(actionResultsPage, true);
throw e;
}
}
currentPage.truncateBacktrackState();
}
actionResultsPage.ensureAwake(requestContext);
formPostFilter(request, requestContext, actionResultsComponent);
session.savePage(actionResultsPage);
/* Performance debugging feature -- replay request N times
-- see AWDebugPane for activation */
_debugRepeatRequest(
requestContext, actionResultsComponent, request);
response = requestContext.generateResponse();
}
else {
response = actionResults.generateResponse();
}
break;
}
default: {
throw new AWGenericException(getClass().getName() +
": unrecognized requestType: " + requestType);
}
}
// Perf trace