From 787fb7dc892a4f7fe7fd976efc7b86e79b363ec0 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Mon, 28 Jan 2013 18:26:40 -0800 Subject: [PATCH] Fix issue with RichFaces file upload Change JsfView.userEventQueued() to check for 'javax.faces.ViewState' via the FacesContext rather than the RequestContext. This allows potential multi-part request submissions to be processed by JSF rather than Spring. Issue: SWF-1482 --- .../org/springframework/faces/webflow/JsfView.java | 13 +++++++++---- .../springframework/faces/webflow/JsfViewTests.java | 6 ++---- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/spring-faces/src/main/java/org/springframework/faces/webflow/JsfView.java b/spring-faces/src/main/java/org/springframework/faces/webflow/JsfView.java index 9562aea3..c9f08d49 100644 --- a/spring-faces/src/main/java/org/springframework/faces/webflow/JsfView.java +++ b/spring-faces/src/main/java/org/springframework/faces/webflow/JsfView.java @@ -1,5 +1,5 @@ /* - * Copyright 2004-2012 the original author or authors. + * Copyright 2004-2013 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,7 +30,7 @@ import org.springframework.webflow.execution.View; /** * JSF-specific {@link View} implementation. - * + * * @author Jeremy Grelle * @author Phillip Webb */ @@ -47,7 +47,7 @@ public class JsfView implements View { private final RequestContext requestContext; private String viewId; - + /** * Creates a new JSF view. * @param viewRoot the view root @@ -97,7 +97,12 @@ public class JsfView implements View { } public boolean userEventQueued() { - return this.requestContext.getRequestParameters().contains("javax.faces.ViewState"); + FacesContext facesContext = FlowFacesContext.getCurrentInstance(); + if (facesContext != null) { + // Use ExternalContext for multipart request parsing by component libraries + return facesContext.getExternalContext().getRequestParameterMap().containsKey("javax.faces.ViewState"); + } + return false; } /** diff --git a/spring-faces/src/test/java/org/springframework/faces/webflow/JsfViewTests.java b/spring-faces/src/test/java/org/springframework/faces/webflow/JsfViewTests.java index 877bc9e4..692d229e 100644 --- a/spring-faces/src/test/java/org/springframework/faces/webflow/JsfViewTests.java +++ b/spring-faces/src/test/java/org/springframework/faces/webflow/JsfViewTests.java @@ -194,11 +194,9 @@ public class JsfViewTests extends TestCase { public final void testUserEventQueued_FormSubmitted() { - MockParameterMap requestParameterMap = new MockParameterMap(); - requestParameterMap.put("execution", "e1s1"); - requestParameterMap.put("javax.faces.ViewState", "e1s1"); + this.jsfMock.request().addParameter("execution", "e1s1"); + this.jsfMock.request().addParameter("javax.faces.ViewState", "e1s1"); - EasyMock.expect(this.context.getRequestParameters()).andStubReturn(requestParameterMap); EasyMock.replay(new Object[] { this.context, this.flowExecutionContext, this.flowMap, this.flashScope }); JsfView createdView = new JsfView(new UIViewRoot(), this.jsfMock.lifecycle(), this.context);