Remove MyFacesFlowResponseStateManager
After #3a165ea MyFacesFlowResponseStateManager no longer serves any purpose and it seems to works without it. Issue: SWF-1712
This commit is contained in:
@@ -1,67 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2012 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.faces.support;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.faces.FacesWrapper;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.render.ResponseStateManager;
|
||||
|
||||
/**
|
||||
* Provides a simple implementation of {@link ResponseStateManager} that can be subclassed by developers wishing to
|
||||
* provide specialized behavior to an existing {@link ResponseStateManager instance} . The default implementation of all
|
||||
* methods is to call through to the wrapped {@link ResponseStateManager}.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
*
|
||||
* @since 2.4
|
||||
*/
|
||||
public abstract class ResponseStateManagerWrapper extends ResponseStateManager implements
|
||||
FacesWrapper<ResponseStateManager> {
|
||||
|
||||
public abstract ResponseStateManager getWrapped();
|
||||
|
||||
@Override
|
||||
public void writeState(FacesContext context, Object state) throws IOException {
|
||||
getWrapped().writeState(context, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getState(FacesContext context, String viewId) {
|
||||
return getWrapped().getState(context, viewId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStateless(FacesContext context, String viewId) {
|
||||
return getWrapped().isStateless(context, viewId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPostback(FacesContext context) {
|
||||
return getWrapped().isPostback(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getViewState(FacesContext context, Object state) {
|
||||
return getWrapped().getViewState(context, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCryptographicallyStrongTokenFromSession(FacesContext context) {
|
||||
return getWrapped().getCryptographicallyStrongTokenFromSession(context);
|
||||
}
|
||||
}
|
||||
@@ -94,12 +94,10 @@ public class FlowApplication extends ApplicationWrapper {
|
||||
return (delegateViewHandler != null) && (!(delegateViewHandler instanceof FlowViewHandler));
|
||||
}
|
||||
|
||||
private boolean wrapAndSetViewHandler(ViewHandler target) {
|
||||
private void wrapAndSetViewHandler(ViewHandler target) {
|
||||
if ((target != null) && (!(target instanceof FlowViewHandler))) {
|
||||
ViewHandler handler = new FlowViewHandler(target);
|
||||
super.setViewHandler(handler);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,10 @@
|
||||
*/
|
||||
package org.springframework.faces.webflow;
|
||||
|
||||
import javax.faces.render.RenderKit;
|
||||
import javax.faces.render.RenderKitWrapper;
|
||||
import javax.faces.render.ResponseStateManager;
|
||||
|
||||
/**
|
||||
* A render kit implementation that ensures use of Web Flow's FlowViewResponseStateManager, which takes over reading and
|
||||
* writing JSF state and manages that in Web Flow's view scope.
|
||||
@@ -23,15 +27,6 @@ package org.springframework.faces.webflow;
|
||||
* @author Phillip Webb
|
||||
* @since 2.2.0
|
||||
*/
|
||||
import java.lang.reflect.Constructor;
|
||||
|
||||
import javax.faces.render.RenderKit;
|
||||
import javax.faces.render.RenderKitWrapper;
|
||||
import javax.faces.render.ResponseStateManager;
|
||||
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
public class FlowRenderKit extends RenderKitWrapper {
|
||||
|
||||
private final RenderKit wrapped;
|
||||
@@ -40,24 +35,7 @@ public class FlowRenderKit extends RenderKitWrapper {
|
||||
|
||||
public FlowRenderKit(RenderKit wrapped) {
|
||||
this.wrapped = wrapped;
|
||||
this.flowViewResponseStateManager = initResponseStateManager(wrapped.getResponseStateManager());
|
||||
}
|
||||
|
||||
private ResponseStateManager initResponseStateManager(ResponseStateManager wrapped) {
|
||||
if (JsfRuntimeInformation.isMojarraPresent() && !JsfRuntimeInformation.isMyFacesInUse()) {
|
||||
return new FlowResponseStateManager(wrapped);
|
||||
}
|
||||
Constructor<?> constructor;
|
||||
try {
|
||||
String className = "org.springframework.faces.webflow.MyFacesFlowResponseStateManager";
|
||||
Class<?> clazz = ClassUtils.forName(className, FlowRenderKit.class.getClassLoader());
|
||||
constructor = ClassUtils.getConstructorIfAvailable(clazz, FlowResponseStateManager.class);
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new IllegalStateException("Could not initialize MyFacesFlowResponseStateManager", e);
|
||||
} catch (LinkageError e) {
|
||||
throw new IllegalStateException("Could not initialize MyFacesFlowResponseStateManager", e);
|
||||
}
|
||||
return (ResponseStateManager) BeanUtils.instantiateClass(constructor, new FlowResponseStateManager(wrapped));
|
||||
this.flowViewResponseStateManager = new FlowResponseStateManager(wrapped.getResponseStateManager());
|
||||
}
|
||||
|
||||
public RenderKit getWrapped() {
|
||||
@@ -74,4 +52,5 @@ public class FlowRenderKit extends RenderKitWrapper {
|
||||
}
|
||||
return this.wrapped.getResponseStateManager();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ package org.springframework.faces.webflow;
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
|
||||
import javax.faces.FacesWrapper;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.context.ResponseWriter;
|
||||
import javax.faces.render.RenderKitFactory;
|
||||
@@ -25,7 +26,7 @@ import javax.faces.render.ResponseStateManager;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.faces.support.ResponseStateManagerWrapper;
|
||||
|
||||
import org.springframework.webflow.execution.RequestContext;
|
||||
import org.springframework.webflow.execution.RequestContextHolder;
|
||||
|
||||
@@ -38,7 +39,8 @@ import org.springframework.webflow.execution.RequestContextHolder;
|
||||
*
|
||||
* @since 2.2.0
|
||||
*/
|
||||
public class FlowResponseStateManager extends ResponseStateManagerWrapper {
|
||||
public class FlowResponseStateManager extends ResponseStateManager
|
||||
implements FacesWrapper<ResponseStateManager> {
|
||||
|
||||
private static final Log logger = LogFactory.getLog(FlowResponseStateManager.class);
|
||||
|
||||
@@ -147,4 +149,15 @@ public class FlowResponseStateManager extends ResponseStateManagerWrapper {
|
||||
writer.endElement("input");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPostback(FacesContext context) {
|
||||
return getWrapped().isPostback(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCryptographicallyStrongTokenFromSession(FacesContext context) {
|
||||
return getWrapped().getCryptographicallyStrongTokenFromSession(context);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,73 +0,0 @@
|
||||
/*
|
||||
* Copyright 2004-2012 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.faces.webflow;
|
||||
|
||||
import javax.faces.FacesWrapper;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.render.ResponseStateManager;
|
||||
|
||||
import org.springframework.faces.support.ResponseStateManagerWrapper;
|
||||
import org.springframework.webflow.execution.RequestContext;
|
||||
import org.springframework.webflow.execution.RequestContextHolder;
|
||||
|
||||
/**
|
||||
* A wrapper for {@link FlowResponseStateManager} used to support MyFaces partial
|
||||
* state saving. MyFaces supports an extension to the {@link ResponseStateManager}
|
||||
* that reduces the amount of buffering required when writing a response. Empty
|
||||
* state is provided at the time that the {@link #writeState(FacesContext, Object)
|
||||
* writeState} method is invoked with an additional
|
||||
* {@link #saveState(FacesContext, Object) saveState} method called later
|
||||
* containing the real state to save.
|
||||
*
|
||||
* <p>Since JSF 2.0, the strategy used by MyFaces to determine if a
|
||||
* {@link org.apache.myfaces.renderkit.MyfacesResponseStateManager} is available
|
||||
* will always succeed since it
|
||||
* follows {@link FacesWrapper}s to find the root <tt>HtmlResponseStateManager</tt>
|
||||
* implementation. Since state management for web flow requests is handled by the
|
||||
* {@link FlowResponseStateManager} this* assumption causes problems and results
|
||||
* in empty state data being saved. This wrapper provides the additional hook
|
||||
* required to ensure that the {@link #saveState(FacesContext, Object) saveState}
|
||||
* method also triggers web flow state management.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @since 2.4
|
||||
* @see FlowResponseStateManager
|
||||
* @see FlowRenderKit
|
||||
*/
|
||||
public class MyFacesFlowResponseStateManager extends ResponseStateManagerWrapper
|
||||
implements FacesWrapper<ResponseStateManager> {
|
||||
|
||||
private final ResponseStateManager wrapped;
|
||||
|
||||
public MyFacesFlowResponseStateManager(FlowResponseStateManager wrapped) {
|
||||
this.wrapped = wrapped;
|
||||
}
|
||||
|
||||
public ResponseStateManager getWrapped() {
|
||||
return this.wrapped;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStateless(FacesContext context, String viewId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void saveState(FacesContext facesContext, Object state) {
|
||||
RequestContext requestContext = RequestContextHolder.getRequestContext();
|
||||
requestContext.getViewScope().put(FlowResponseStateManager.FACES_VIEW_STATE, state);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user