This commit is contained in:
Keith Donald
2009-04-06 21:58:45 +00:00
parent a1ed5ac6d9
commit 47dc9327ae
2 changed files with 34 additions and 37 deletions

View File

@@ -18,7 +18,6 @@ package org.springframework.webflow.engine;
import org.springframework.binding.mapping.Mapper;
import org.springframework.binding.mapping.MappingResults;
import org.springframework.core.style.ToStringCreator;
import org.springframework.webflow.context.ExternalContext;
import org.springframework.webflow.core.collection.LocalAttributeMap;
import org.springframework.webflow.execution.Action;
import org.springframework.webflow.execution.ActionExecutor;
@@ -97,7 +96,7 @@ public class EndState extends State {
FlowSession activeSession = context.getFlowExecutionContext().getActiveSession();
if (activeSession.isRoot()) {
// entire flow execution is ending; issue the final response
if (finalResponseAction != null && canSendResponse(context.getExternalContext())) {
if (finalResponseAction != null && !context.getExternalContext().isResponseComplete()) {
ActionExecutor.execute(finalResponseAction, context);
context.getExternalContext().recordResponseComplete();
}
@@ -124,10 +123,6 @@ public class EndState extends State {
return output;
}
private boolean canSendResponse(ExternalContext context) {
return context.isResponseAllowed() && !context.isResponseComplete();
}
protected void appendToString(ToStringCreator creator) {
creator.append("finalResponseAction", finalResponseAction).append("outputMapper", outputMapper);
}

View File

@@ -170,18 +170,16 @@ public class ViewState extends TransitionableState {
protected void doEnter(RequestControlContext context) throws FlowExecutionException {
context.assignFlowExecutionKey();
ExternalContext externalContext = context.getExternalContext();
if (externalContext.isResponseAllowed()) {
if (externalContext.isResponseComplete()) {
if (!externalContext.isRedirectRequested()) {
clearFlash(context);
if (externalContext.isResponseComplete()) {
clearFlashIfRenderResponse(context);
} else {
if (shouldRedirect(context)) {
context.getExternalContext().requestFlowExecutionRedirect();
if (popup) {
context.getExternalContext().requestRedirectInPopup();
}
} else {
if (shouldRedirect(context)) {
context.getExternalContext().requestFlowExecutionRedirect();
if (popup) {
context.getExternalContext().requestRedirectInPopup();
}
} else {
if (externalContext.isResponseAllowed()) {
View view = viewFactory.getView(context);
render(context, view);
}
@@ -201,34 +199,26 @@ public class ViewState extends TransitionableState {
boolean stateExited = context.handleEvent(event);
if (!stateExited) {
ExternalContext externalContext = context.getExternalContext();
if (externalContext.isResponseAllowed()) {
if (externalContext.isResponseComplete()) {
if (!externalContext.isRedirectRequested()) {
clearFlash(context);
}
if (externalContext.isResponseComplete()) {
clearFlashIfRenderResponse(context);
} else {
if (externalContext.isAjaxRequest()) {
renderIfAllowed(context, view);
} else {
if (externalContext.isAjaxRequest()) {
render(context, view);
if (shouldRedirect(context)) {
externalContext.requestFlowExecutionRedirect();
} else {
if (shouldRedirect(context)) {
externalContext.requestFlowExecutionRedirect();
} else {
render(context, view);
}
renderIfAllowed(context, view);
}
}
}
}
} else {
ExternalContext externalContext = context.getExternalContext();
if (externalContext.isResponseAllowed()) {
if (externalContext.isResponseComplete()) {
if (!externalContext.isRedirectRequested()) {
clearFlash(context);
}
} else {
render(context, view);
}
if (externalContext.isResponseComplete()) {
clearFlashIfRenderResponse(context);
} else {
renderIfAllowed(context, view);
}
}
}
@@ -260,6 +250,12 @@ public class ViewState extends TransitionableState {
}
}
private void renderIfAllowed(RequestControlContext context, View view) throws ViewRenderingException {
if (context.getExternalContext().isResponseAllowed()) {
render(context, view);
}
}
private void render(RequestControlContext context, View view) throws ViewRenderingException {
if (logger.isDebugEnabled()) {
logger.debug("Rendering + " + view);
@@ -278,7 +274,13 @@ public class ViewState extends TransitionableState {
context.viewRendered(view);
}
private void clearFlash(RequestControlContext context) {
private void clearFlashIfRenderResponse(RequestContext context) {
if (context.getExternalContext().isResponseAllowed() && !context.getExternalContext().isRedirectRequested()) {
clearFlash(context);
}
}
private void clearFlash(RequestContext context) {
context.getFlashScope().clear();
context.getMessageContext().clearMessages();
}