now respecting response complete status in view-state

This commit is contained in:
Keith Donald
2009-03-12 21:33:40 +00:00
parent dd892345c5
commit 5ec67fbc3e
2 changed files with 16 additions and 6 deletions

View File

@@ -18,6 +18,7 @@ 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;
@@ -83,8 +84,8 @@ public class EndState extends State {
}
/**
* Specialization of State's <code>doEnter</code> template method that executes behavior specific to this state
* type in polymorphic fashion.
* Specialization of State's <code>doEnter</code> template method that executes behavior specific to this state type
* in polymorphic fashion.
* <p>
* This implementation pops the top (active) flow session off the execution stack, ending it, and resumes control in
* the parent flow (if necessary). If the ended session is the root flow, a final response is rendered.
@@ -96,7 +97,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 && context.getExternalContext().isResponseAllowed()) {
if (finalResponseAction != null && canSendResponse(context.getExternalContext())) {
ActionExecutor.execute(finalResponseAction, context);
context.getExternalContext().recordResponseComplete();
}
@@ -123,6 +124,10 @@ 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

@@ -22,6 +22,7 @@ import java.util.Map;
import org.springframework.core.style.ToStringCreator;
import org.springframework.util.Assert;
import org.springframework.webflow.context.ExternalContext;
import org.springframework.webflow.definition.TransitionDefinition;
import org.springframework.webflow.execution.Event;
import org.springframework.webflow.execution.FlowExecutionException;
@@ -168,7 +169,7 @@ public class ViewState extends TransitionableState {
protected void doEnter(RequestControlContext context) throws FlowExecutionException {
context.assignFlowExecutionKey();
if (context.getExternalContext().isResponseAllowed()) {
if (canSendResponse(context.getExternalContext())) {
if (shouldRedirect(context)) {
context.getExternalContext().requestFlowExecutionRedirect();
if (popup) {
@@ -191,7 +192,7 @@ public class ViewState extends TransitionableState {
logger.debug("Event '" + event.getId() + "' returned from view " + view);
}
boolean stateExited = context.handleEvent(event);
if (!stateExited && context.getExternalContext().isResponseAllowed()) {
if (!stateExited && canSendResponse(context.getExternalContext())) {
if (context.getExternalContext().isAjaxRequest()) {
render(context, view);
} else {
@@ -203,7 +204,7 @@ public class ViewState extends TransitionableState {
}
}
} else {
if (context.getExternalContext().isResponseAllowed()) {
if (canSendResponse(context.getExternalContext())) {
render(context, view);
}
}
@@ -228,6 +229,10 @@ public class ViewState extends TransitionableState {
}
}
private boolean canSendResponse(ExternalContext context) {
return context.isResponseAllowed() && !context.isResponseComplete();
}
private boolean shouldRedirect(RequestControlContext context) {
if (redirect != null) {
return redirect.booleanValue();