org.springframework.faces.webflow.Jsf2FlowFacesContext Maven / Gradle / Ivy
/*
* Copyright 2004-2010 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 java.io.IOException;
import java.io.OutputStream;
import java.io.Writer;
import java.util.List;
import java.util.Map;
import javax.faces.FactoryFinder;
import javax.faces.application.FacesMessage;
import javax.faces.application.ProjectStage;
import javax.faces.context.ExceptionHandler;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.faces.context.Flash;
import javax.faces.context.PartialViewContext;
import javax.faces.context.PartialViewContextFactory;
import javax.faces.event.PhaseId;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.webflow.execution.RequestContext;
/**
* Extends FlowFacesContext in order to provide JSF 2 delegation method.
*
* @author Rossen Stoyanchev
*/
public class Jsf2FlowFacesContext extends FlowFacesContext {
private ExternalContext externalContext;
/*
* This partialViewContext duplicates the one FacesContextImpl because the constructor of FacesContextImpl calls
* getPartialViewContext(), which causes it to be instantiated with an instance of FacesContextImpl. This leads to
* issues with adding and showing validation messages during Ajax requests because the FlowFacesContext is
* effectively bypassed.
*/
private PartialViewContext partialViewContext;
public Jsf2FlowFacesContext(RequestContext context, FacesContext delegate) {
super(context, delegate);
this.externalContext = new Jsf2FlowExternalContext(getDelegate().getExternalContext());
PartialViewContextFactory f = (PartialViewContextFactory) FactoryFinder
.getFactory(FactoryFinder.PARTIAL_VIEW_CONTEXT_FACTORY);
this.partialViewContext = f.getPartialViewContext(this);
}
public ExternalContext getExternalContext() {
return externalContext;
}
// --------------- JSF 2.0 Pass-through delegate methods ------------------//
public Map