SWF-963 - Render phase ignores facesContext.responseComplete

This commit is contained in:
Jeremy Grelle
2008-12-09 20:14:27 +00:00
parent 9b52a47d84
commit 159cbd8403
3 changed files with 7 additions and 23 deletions

View File

@@ -46,18 +46,13 @@ import org.springframework.webflow.execution.RequestContext;
/**
* Custom {@link FacesContext} implementation that delegates all standard FacesContext messaging functionality to a
* Spring {@link MessageSource} made accessible as part of the current Web Flow request. Additionally, it manages the
* {@code responseComplete} and {@code renderResponse} flags in flash scope so that the execution of the JSF
* {@link Lifecycle} may span multiple requests in the case of the POST+REDIRECT+GET pattern being enabled.
* {@code renderResponse} flag in flash scope so that the execution of the JSF {@link Lifecycle} may span multiple
* requests in the case of the POST+REDIRECT+GET pattern being enabled.
*
* @author Jeremy Grelle
*/
public class FlowFacesContext extends FacesContext {
/**
* The key for storing the responseComplete flag
*/
static final String RESPONSE_COMPLETE_KEY = "flowResponseComplete";
/**
* The key for storing the renderResponse flag
*/
@@ -204,11 +199,7 @@ public class FlowFacesContext extends FacesContext {
}
public boolean getResponseComplete() {
Boolean responseComplete = context.getFlashScope().getBoolean(RESPONSE_COMPLETE_KEY);
if (responseComplete == null) {
return false;
}
return responseComplete.booleanValue();
return context.getExternalContext().isResponseComplete();
}
public void renderResponse() {
@@ -217,7 +208,7 @@ public class FlowFacesContext extends FacesContext {
}
public void responseComplete() {
context.getFlashScope().put(RESPONSE_COMPLETE_KEY, Boolean.TRUE);
context.getExternalContext().recordResponseComplete();
}
// ------------------ Pass-through delegate methods ----------------------//

View File

@@ -87,6 +87,9 @@ public class JsfView implements View {
*/
public void render() throws IOException {
FacesContext facesContext = FlowFacesContext.newInstance(requestContext, facesLifecycle);
if (facesContext.getResponseComplete()) {
return;
}
facesContext.setViewRoot(viewRoot);
try {
JsfUtils.notifyBeforeListeners(PhaseId.RENDER_RESPONSE, facesLifecycle, facesContext);

View File

@@ -99,8 +99,6 @@ public class JsfViewTests extends TestCase {
EasyMock.expect(flashScope.put(EasyMock.matches(FlowFacesContext.RENDER_RESPONSE_KEY), EasyMock.anyObject()))
.andStubReturn(null);
EasyMock.expect(flashScope.put(EasyMock.matches(FlowFacesContext.RESPONSE_COMPLETE_KEY), EasyMock.anyObject()))
.andStubReturn(null);
EasyMock.replay(new Object[] { context, flowExecutionContext, flowMap, flashScope });
@@ -113,8 +111,6 @@ public class JsfViewTests extends TestCase {
EasyMock.expect(flashScope.put(EasyMock.matches(FlowFacesContext.RENDER_RESPONSE_KEY), EasyMock.anyObject()))
.andStubReturn(null);
EasyMock.expect(flashScope.put(EasyMock.matches(FlowFacesContext.RESPONSE_COMPLETE_KEY), EasyMock.anyObject()))
.andStubReturn(null);
EasyMock.replay(new Object[] { context, flowExecutionContext, flowMap, flashScope });
@@ -132,8 +128,6 @@ public class JsfViewTests extends TestCase {
*/
public final void testResume_Restored_NoEvent() {
EasyMock.expect(flashScope.getBoolean(EasyMock.matches(FlowFacesContext.RESPONSE_COMPLETE_KEY))).andStubReturn(
Boolean.FALSE);
EasyMock.expect(flashScope.getBoolean(EasyMock.matches(FlowFacesContext.RENDER_RESPONSE_KEY))).andStubReturn(
Boolean.FALSE);
EasyMock.expect(flashScope.put(EasyMock.matches(ViewRootHolder.VIEW_ROOT_HOLDER_KEY), EasyMock.anyObject()))
@@ -163,8 +157,6 @@ public class JsfViewTests extends TestCase {
*/
public final void testGetView_Restore_Ajax_NoEvent() {
EasyMock.expect(flashScope.getBoolean(EasyMock.matches(FlowFacesContext.RESPONSE_COMPLETE_KEY))).andStubReturn(
Boolean.FALSE);
EasyMock.expect(flashScope.getBoolean(EasyMock.matches(FlowFacesContext.RENDER_RESPONSE_KEY))).andStubReturn(
Boolean.FALSE);
EasyMock.expect(flashScope.put(EasyMock.matches(ViewRootHolder.VIEW_ROOT_HOLDER_KEY), EasyMock.anyObject()))
@@ -194,8 +186,6 @@ public class JsfViewTests extends TestCase {
*/
public final void testGetView_Restore_EventSignaled() {
EasyMock.expect(flashScope.getBoolean(EasyMock.matches(FlowFacesContext.RESPONSE_COMPLETE_KEY))).andStubReturn(
Boolean.FALSE);
EasyMock.expect(flashScope.getBoolean(EasyMock.matches(FlowFacesContext.RENDER_RESPONSE_KEY))).andStubReturn(
Boolean.FALSE);
EasyMock.expect(flashScope.put(EasyMock.matches(ViewRootHolder.VIEW_ROOT_HOLDER_KEY), EasyMock.anyObject()))