SWF-538 - JSFViewFactory's execution of the restore view lifecycle doesn't appear to match the JSF spec.
This commit is contained in:
@@ -1,16 +0,0 @@
|
||||
package org.springframework.faces.mvc;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import org.springframework.web.servlet.mvc.AbstractController;
|
||||
|
||||
public class JsfController extends AbstractController {
|
||||
|
||||
protected ModelAndView handleRequestInternal(HttpServletRequest arg0, HttpServletResponse arg1) throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Auto-generated method stub");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -21,6 +21,7 @@ import java.util.Map;
|
||||
|
||||
import javax.faces.FacesException;
|
||||
import javax.faces.FactoryFinder;
|
||||
import javax.faces.application.ViewHandler;
|
||||
import javax.faces.component.UIViewRoot;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.context.FacesContextFactory;
|
||||
@@ -58,7 +59,13 @@ public class JsfView extends AbstractUrlBasedView {
|
||||
|
||||
JsfUtils.notifyBeforeListeners(PhaseId.RESTORE_VIEW, facesLifecycle, facesContext);
|
||||
|
||||
UIViewRoot viewRoot = facesContext.getApplication().getViewHandler().createView(facesContext, getUrl());
|
||||
ViewHandler viewHandler = facesContext.getApplication().getViewHandler();
|
||||
|
||||
if (JsfUtils.isAtLeastJsf12()) {
|
||||
viewHandler.initView(facesContext);
|
||||
}
|
||||
|
||||
UIViewRoot viewRoot = viewHandler.createView(facesContext, getUrl());
|
||||
|
||||
Assert.notNull(viewRoot, "A JSF view could not be created for " + getUrl());
|
||||
viewRoot.setTransient(true);
|
||||
|
||||
@@ -33,8 +33,6 @@ public class FlowViewStateManager extends StateManager {
|
||||
|
||||
private static final String SERIALIZED_VIEW_STATE = "org.springframework.webflow.viewState";
|
||||
|
||||
private static final String ACTIVE_VIEW_ROOT = "org.springframework.webflow.viewRoot";
|
||||
|
||||
private StateManager delegate;
|
||||
|
||||
public FlowViewStateManager(StateManager original) {
|
||||
@@ -91,7 +89,7 @@ public class FlowViewStateManager extends StateManager {
|
||||
return null;
|
||||
}
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Restoring view root with id '" + viewId + "' from flow scope");
|
||||
logger.debug("Restoring view root with id '" + viewId + "' from view scope");
|
||||
}
|
||||
if (view.treeStructure == null) {
|
||||
logger.debug("Tree structure is null indicating transient UIViewRoot; returning null");
|
||||
@@ -141,7 +139,7 @@ public class FlowViewStateManager extends StateManager {
|
||||
|
||||
RequestContext requestContext = RequestContextHolder.getRequestContext();
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Saving view root '" + context.getViewRoot().getViewId() + "' in flow scope");
|
||||
logger.debug("Saving view root '" + context.getViewRoot().getViewId() + "' in view scope");
|
||||
}
|
||||
SerializedView view = new SerializedView(context.getViewRoot().getViewId(), getTreeStructureToSave(context),
|
||||
getComponentStateToSave(context));
|
||||
|
||||
@@ -21,6 +21,7 @@ import javax.faces.event.PhaseId;
|
||||
import javax.faces.event.PhaseListener;
|
||||
import javax.faces.lifecycle.Lifecycle;
|
||||
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
import org.springframework.webflow.execution.RequestContextHolder;
|
||||
|
||||
/**
|
||||
@@ -30,6 +31,18 @@ import org.springframework.webflow.execution.RequestContextHolder;
|
||||
*/
|
||||
public class JsfUtils {
|
||||
|
||||
private static final boolean JSF_12;
|
||||
|
||||
private static final String JSF_12_METHOD = "getELContext";
|
||||
|
||||
static {
|
||||
if (ReflectionUtils.findMethod(FacesContext.class, JSF_12_METHOD) != null) {
|
||||
JSF_12 = true;
|
||||
} else {
|
||||
JSF_12 = false;
|
||||
}
|
||||
}
|
||||
|
||||
public static void notifyAfterListeners(PhaseId phaseId, Lifecycle lifecycle, FacesContext context) {
|
||||
PhaseEvent afterPhaseEvent = new PhaseEvent(context, phaseId, lifecycle);
|
||||
for (int i = 0; i < lifecycle.getPhaseListeners().length; i++) {
|
||||
@@ -65,4 +78,8 @@ public class JsfUtils {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isAtLeastJsf12() {
|
||||
return JSF_12;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,6 +78,10 @@ public class JsfViewFactory implements ViewFactory {
|
||||
String viewName = resolveViewName(context);
|
||||
ViewHandler viewHandler = facesContext.getApplication().getViewHandler();
|
||||
|
||||
if (JsfUtils.isAtLeastJsf12()) {
|
||||
viewHandler.initView(facesContext);
|
||||
}
|
||||
|
||||
if (viewExists(facesContext, viewName)) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Existing view root found for '" + viewName + "'");
|
||||
|
||||
@@ -40,6 +40,10 @@ public class MockViewHandler extends ViewHandler {
|
||||
return createViewRoot;
|
||||
}
|
||||
|
||||
public void initView(FacesContext context) throws FacesException {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the view root that this mock is supposed to create
|
||||
* @param createViewRoot the view to set.
|
||||
|
||||
Reference in New Issue
Block a user