SWF-953 - View data binding results lost after Action phase in Portlet environment, not propogating to Render phase.

This commit is contained in:
Jeremy Grelle
2008-11-13 22:33:09 +00:00
parent a306c779f8
commit 588b3bc29e
3 changed files with 66 additions and 3 deletions

View File

@@ -71,6 +71,9 @@ public class FlowViewHandler extends ViewHandler {
String resourcePath = viewId;
if (JsfUtils.isFlowRequest()) {
resourcePath = resolveResourcePath(RequestContextHolder.getRequestContext(), viewId);
if (JsfUtils.isPortlet(context)) {
return restoreFlowPortletView(context, resourcePath);
}
}
return delegate.restoreView(context, resourcePath);
}
@@ -117,4 +120,14 @@ public class FlowViewHandler extends ViewHandler {
}
}
private UIViewRoot restoreFlowPortletView(FacesContext facesContext, String resourcePath) {
RequestContext context = RequestContextHolder.getRequestContext();
ViewRootHolder holder = (ViewRootHolder) context.getFlashScope().get(ViewRootHolder.VIEW_ROOT_HOLDER_KEY);
if (holder != null && holder.getViewRoot().getViewId().equals(resourcePath)) {
return holder.getViewRoot();
} else {
return delegate.restoreView(facesContext, resourcePath);
}
}
}

View File

@@ -49,8 +49,6 @@ public class JsfView implements View {
private boolean restored;
private boolean viewErrors;
/**
* Creates a new JSF view.
* @param viewRoot the view root
@@ -72,6 +70,10 @@ public class JsfView implements View {
return this.viewRoot;
}
public void setViewRoot(UIViewRoot viewRoot) {
this.viewRoot = viewRoot;
}
/**
* Sets whether or not the view root for this view was restored from storage or is new.
* @param restored true or false
@@ -109,13 +111,17 @@ public class JsfView implements View {
if (restored && !facesContext.getRenderResponse() && !facesContext.getResponseComplete()) {
facesLifecycle.execute(facesContext);
}
if (JsfUtils.isPortlet(facesContext)) {
requestContext.getFlashScope().put(ViewRootHolder.VIEW_ROOT_HOLDER_KEY,
new ViewRootHolder(getViewRoot()));
}
} finally {
facesContext.release();
}
}
public boolean hasFlowEvent() {
return requestContext.getExternalContext().getRequestMap().contains(EVENT_KEY) && !viewErrors;
return requestContext.getExternalContext().getRequestMap().contains(EVENT_KEY);
}
public Event getFlowEvent() {
@@ -131,4 +137,5 @@ public class JsfView implements View {
private String getEventId() {
return (String) requestContext.getExternalContext().getRequestMap().get(EVENT_KEY);
}
}

View File

@@ -0,0 +1,43 @@
/*
* Copyright 2004-2008 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.component.UIViewRoot;
/**
* Holder for the JSF UIViewRoot
*
* @author Scott Andrews
*/
class ViewRootHolder {
static final String VIEW_ROOT_HOLDER_KEY = "org.springframework.faces.webflow.VIEW_ROOT_HOLDER";
private UIViewRoot viewRoot;
public ViewRootHolder(UIViewRoot viewRoot) {
this.viewRoot = viewRoot;
}
public UIViewRoot getViewRoot() {
return viewRoot;
}
public void setViewRoot(UIViewRoot viewRoot) {
this.viewRoot = viewRoot;
}
}