Revert "Prevent NPE in Mojarra when creating initial view"
This reverts commit d31900e5f9.
The fix for SWF-1571 reported against Mojarra 2.1.8 seems to be
problematic when Web Flow's ResponseStateManager is not used as
reported in SWF-1630.
Testing with Mojarra 2.1.20 I can no longer reproduce SWF-1571
and originally it was suspected to be a Mojarra issue. Hence
this revert.
Issue: SWF-1571, SWF-1630
This commit is contained in:
@@ -142,13 +142,4 @@ public class FlowResponseStateManager extends ResponseStateManagerWrapper {
|
||||
writer.endElement("input");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the request context has existing state.
|
||||
* @param context the request context
|
||||
* @return {@code true} if the context has state
|
||||
*/
|
||||
static boolean hasState(RequestContext context) {
|
||||
return (context != null) && (context.getViewScope().contains(FACES_VIEW_STATE));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,12 +132,7 @@ public class JsfViewFactory implements ViewFactory {
|
||||
|
||||
private UIViewRoot getViewStateViewRoot(RequestContext context, FacesContext facesContext, ViewHandler viewHandler,
|
||||
String viewName) {
|
||||
UIViewRoot viewRoot = null;
|
||||
if (FlowResponseStateManager.hasState(context)) {
|
||||
// Only try an initial restore if we have state (see SWF-1571)
|
||||
viewRoot = viewHandler.restoreView(facesContext, viewName);
|
||||
}
|
||||
|
||||
UIViewRoot viewRoot = viewHandler.restoreView(facesContext, viewName);
|
||||
if (viewRoot != null) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("UIViewRoot restored for '" + viewName + "'");
|
||||
@@ -149,7 +144,6 @@ public class JsfViewFactory implements ViewFactory {
|
||||
}
|
||||
viewRoot = viewHandler.createView(facesContext, viewName);
|
||||
}
|
||||
|
||||
return viewRoot;
|
||||
}
|
||||
|
||||
|
||||
@@ -72,15 +72,12 @@ public class JsfViewFactoryTests extends TestCase {
|
||||
|
||||
private final MockHttpServletResponse response = new MockHttpServletResponse();
|
||||
|
||||
private LocalAttributeMap<Object> viewScope = new LocalAttributeMap<Object>();
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
configureJsf();
|
||||
this.extContext.setNativeContext(this.servletContext);
|
||||
this.extContext.setNativeRequest(this.request);
|
||||
this.extContext.setNativeResponse(this.response);
|
||||
RequestContextHolder.setRequestContext(this.context);
|
||||
EasyMock.expect(this.context.getViewScope()).andStubReturn(this.viewScope);
|
||||
EasyMock.expect(this.context.getFlashScope()).andStubReturn(this.flashMap);
|
||||
EasyMock.expect(this.context.getExternalContext()).andStubReturn(this.extContext);
|
||||
EasyMock.expect(this.context.getRequestParameters()).andStubReturn(
|
||||
@@ -151,7 +148,6 @@ public class JsfViewFactoryTests extends TestCase {
|
||||
EasyMock.expectLastCall().andReturn(true);
|
||||
|
||||
EasyMock.replay(new Object[] { this.context });
|
||||
setupViewState();
|
||||
|
||||
View restoredView = this.factory.getView(this.context);
|
||||
|
||||
@@ -198,7 +194,6 @@ public class JsfViewFactoryTests extends TestCase {
|
||||
EasyMock.expectLastCall().andReturn(true);
|
||||
|
||||
EasyMock.replay(new Object[] { this.context });
|
||||
setupViewState();
|
||||
|
||||
View restoredView = this.factory.getView(this.context);
|
||||
|
||||
@@ -234,7 +229,6 @@ public class JsfViewFactoryTests extends TestCase {
|
||||
EasyMock.expectLastCall().andReturn(true);
|
||||
|
||||
EasyMock.replay(new Object[] { this.context });
|
||||
setupViewState();
|
||||
|
||||
View restoredView = this.factory.getView(this.context);
|
||||
|
||||
@@ -285,7 +279,6 @@ public class JsfViewFactoryTests extends TestCase {
|
||||
|
||||
this.context.inViewState();
|
||||
EasyMock.expectLastCall().andReturn(true);
|
||||
setupViewState();
|
||||
|
||||
EasyMock.replay(new Object[] { this.context });
|
||||
this.factory.getView(this.context);
|
||||
@@ -296,10 +289,6 @@ public class JsfViewFactoryTests extends TestCase {
|
||||
.getExceptionQueuedEventContext().getException());
|
||||
}
|
||||
|
||||
private void setupViewState() {
|
||||
this.viewScope.put(FlowResponseStateManager.FACES_VIEW_STATE, "X");
|
||||
}
|
||||
|
||||
private class NoExecutionLifecycle extends FlowLifecycle {
|
||||
|
||||
public NoExecutionLifecycle(Lifecycle delegate) {
|
||||
|
||||
Reference in New Issue
Block a user