SWF-1194 Upgrade to JSF 2

This commit is contained in:
Rossen Stoyanchev
2010-05-17 10:23:15 +00:00
parent 968014b4d7
commit 0f84b153b5
33 changed files with 576 additions and 82 deletions

View File

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<ivysettings>
<include file="${spring.build.dir}/common/ivysettings.xml"/>
<settings defaultResolver="extended-external-lookup" defaultLatestStrategy="latest-lexico"/>
<resolvers>
<chain name="extended-external-lookup">
<resolver ref="external-lookup"/>
<url name="java-net-maven2" m2compatible="true">
<artifact pattern="http://download.java.net/maven/2/[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier]).[ext]"/>
</url>
<ibiblio name="maven2" m2compatible="true"/>
</chain>
</resolvers>
</ivysettings>

View File

@@ -4,10 +4,11 @@ natural.name=spring-webflow
project.key=SWF
ivy.cache.dir=${basedir}/../ivy-cache
integration.repo.dir=${basedir}/../integration-repo
source.version=1.4
source.version=1.5
javadoc.exclude.package.names=org/springframework/webflow/samples/**
javadoc.max.memory=256M
test.vm.args=-XX:MaxPermSize=128M
ivy.settings.file=${basedir}/../build-spring-webflow/ivysettings.xml
# For when releasing
#release.type=release

View File

@@ -9,8 +9,8 @@
<classpathentry combineaccessrules="false" kind="src" path="/spring-webflow"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="var" path="IVY_CACHE/com.sun.facelets/com.springsource.com.sun.facelets/1.1.14/com.springsource.com.sun.facelets-1.1.14.jar" sourcepath="IVY_CACHE/com.sun.facelets/com.springsource.com.sun.facelets/1.1.14/com.springsource.com.sun.facelets-sources-1.1.14.jar"/>
<classpathentry kind="var" path="IVY_CACHE/com.sun.faces/com.springsource.com.sun.faces/1.2.0.09/com.springsource.com.sun.faces-1.2.0.09.jar" sourcepath="/IVY_CACHE/com.sun.faces/com.springsource.com.sun.faces/1.2.0.09/com.springsource.com.sun.faces-sources-1.2.0.09.jar"/>
<classpathentry kind="var" path="IVY_CACHE/javax.faces/com.springsource.javax.faces/1.2.0.09/com.springsource.javax.faces-1.2.0.09.jar" sourcepath="/IVY_CACHE/javax.faces/com.springsource.javax.faces/1.2.0.09/com.springsource.javax.faces-sources-1.2.0.09.jar"/>
<classpathentry kind="var" path="IVY_CACHE/com.sun.faces/jsf-impl/2.0.2/jsf-impl-2.0.2.jar" sourcepath="/IVY_CACHE/com.sun.faces/jsf-impl/2.0.2/jsf-impl-2.0.2-sources.jar"/>
<classpathentry kind="var" path="IVY_CACHE/javax.faces/jsf-api/2.0/jsf-api-2.0.jar" sourcepath="/IVY_CACHE/javax.faces/jsf-api/2.0/jsf-api-2.0-sources.jar"/>
<classpathentry kind="var" path="IVY_CACHE/javax.el/com.springsource.javax.el/1.0.0/com.springsource.javax.el-1.0.0.jar" sourcepath="IVY_CACHE/javax.el/com.springsource.javax.el/1.0.0/com.springsource.javax.el-sources-1.0.0.jar"/>
<classpathentry kind="var" path="IVY_CACHE/javax.servlet/com.springsource.javax.servlet/2.4.0/com.springsource.javax.servlet-2.4.0.jar" sourcepath="/IVY_CACHE/javax.servlet/com.springsource.javax.servlet/2.4.0/com.springsource.javax.servlet-sources-2.4.0.jar"/>
<classpathentry kind="var" path="IVY_CACHE/org.apache.commons/com.springsource.org.apache.commons.logging/1.1.1/com.springsource.org.apache.commons.logging-1.1.1.jar" sourcepath="IVY_CACHE/org.apache.commons/com.springsource.org.apache.commons.logging/1.1.1/com.springsource.org.apache.commons.logging-sources-1.1.1.jar"/>
@@ -18,7 +18,7 @@
<classpathentry kind="var" path="IVY_CACHE/org.apache.commons/com.springsource.org.apache.commons.collections/3.2.0/com.springsource.org.apache.commons.collections-3.2.0.jar" sourcepath="IVY_CACHE/org.apache.commons/com.springsource.org.apache.commons.collections/3.2.0/com.springsource.org.apache.commons.collections-sources-3.2.0.jar"/>
<classpathentry kind="var" path="IVY_CACHE/org.apache.commons/com.springsource.org.apache.commons.digester/1.8.0/com.springsource.org.apache.commons.digester-1.8.0.jar" sourcepath="IVY_CACHE/org.apache.commons/com.springsource.org.apache.commons.digester/1.8.0/com.springsource.org.apache.commons.digester-sources-1.8.0.jar"/>
<classpathentry kind="var" path="IVY_CACHE/org.apache.log4j/com.springsource.org.apache.log4j/1.2.15/com.springsource.org.apache.log4j-1.2.15.jar" sourcepath="IVY_CACHE/org.apache.log4j/com.springsource.org.apache.log4j/1.2.15/com.springsource.org.apache.log4j-sources-1.2.15.jar"/>
<classpathentry kind="var" path="IVY_CACHE/org.apache.shale/com.springsource.org.apache.shale.test/1.0.4/com.springsource.org.apache.shale.test-1.0.4.jar" sourcepath="IVY_CACHE/org.apache.shale/com.springsource.org.apache.shale.test/1.0.4/com.springsource.org.apache.shale.test-sources-1.0.4.jar"/>
<classpathentry kind="var" path="IVY_CACHE/org.apache.myfaces.test/myfaces-test20/1.0.0-beta/myfaces-test20-1.0.0-beta.jar" sourcepath="/IVY_CACHE/org.apache.myfaces.test/myfaces-test20/1.0.0-beta/myfaces-test20-1.0.0-beta-sources.jar"/>
<classpathentry kind="var" path="IVY_CACHE/org.easymock/com.springsource.org.easymock/2.3.0/com.springsource.org.easymock-2.3.0.jar" sourcepath="IVY_CACHE/org.easymock/com.springsource.org.easymock/2.3.0/com.springsource.org.easymock-sources-2.3.0.jar"/>
<classpathentry kind="var" path="IVY_CACHE/org.jboss.el/com.springsource.org.jboss.el/2.0.0.GA/com.springsource.org.jboss.el-2.0.0.GA.jar" sourcepath="IVY_CACHE/org.jboss.el/com.springsource.org.jboss.el/2.0.0.GA/com.springsource.org.jboss.el-sources-2.0.0.GA.jar"/>
<classpathentry kind="var" path="IVY_CACHE/org.junit/com.springsource.junit/3.8.2/com.springsource.junit-3.8.2.jar" sourcepath="IVY_CACHE/org.junit/com.springsource.junit/3.8.2/com.springsource.junit-sources-3.8.2.jar"/>

View File

@@ -1,4 +1,4 @@
#Thu Jul 10 09:40:54 BST 2008
#Fri May 14 17:56:46 BST 2010
eclipse.preferences.version=1
org.eclipse.jdt.core.codeComplete.argumentPrefixes=
org.eclipse.jdt.core.codeComplete.argumentSuffixes=
@@ -9,22 +9,22 @@ org.eclipse.jdt.core.codeComplete.localSuffixes=
org.eclipse.jdt.core.codeComplete.staticFieldPrefixes=
org.eclipse.jdt.core.codeComplete.staticFieldSuffixes=
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.4
org.eclipse.jdt.core.compiler.compliance=1.5
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.doc.comment.support=enabled
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
org.eclipse.jdt.core.compiler.problem.deprecation=warning
org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
@@ -79,7 +79,7 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=di
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
org.eclipse.jdt.core.compiler.source=1.3
org.eclipse.jdt.core.compiler.source=1.5
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16

View File

@@ -11,6 +11,7 @@
<configurations>
<include file="${spring.build.dir}/common/default-ivy-configurations.xml"/>
<conf name="jsf20" visibility="public"/>
<conf name="jsf12" visibility="public"/>
<conf name="jsf11" visibility="public"/>
</configurations>
@@ -37,6 +38,10 @@
<dependency org="org.springframework.webflow" name="org.springframework.js" rev="latest.integration" conf="compile->runtime"/>
<dependency org="org.springframework.webflow" name="org.springframework.webflow" rev="latest.integration" conf="compile->runtime"/>
<!-- JSF 2.0 dependencies -->
<dependency org="javax.faces" name="jsf-api" rev="2.0" conf="provided,jsf20->runtime(*)" />
<dependency org="com.sun.faces" name="jsf-impl" rev="2.0.2" conf="provided,jsf20->runtime(*)" />
<!-- JSF 1.2 dependencies -->
<dependency org="javax.faces" name="com.springsource.javax.faces" rev="1.2.0.09" conf="provided, jsf12->runtime" />
<dependency org="com.sun.faces" name="com.springsource.com.sun.faces" rev="1.2.0.09" conf="provided, jsf12->runtime" />
@@ -48,6 +53,7 @@
<!-- test time only dependencies -->
<dependency org="org.apache.log4j" name="com.springsource.org.apache.log4j" rev="1.2.15" conf="test->runtime" />
<dependency org="org.apache.shale" name="com.springsource.org.apache.shale.test" rev="1.0.4" conf="test->runtime" />
<dependency org="org.apache.myfaces.test" name="myfaces-test20" rev="1.0.0-beta" conf="test->default" />
<dependency org="org.easymock" name="com.springsource.org.easymock" rev="2.3.0" conf="test->runtime" />
<dependency org="org.junit" name="com.springsource.junit" rev="3.8.2" conf="test->runtime" />
<dependency org="org.jboss.el" name="com.springsource.org.jboss.el" rev="2.0.0.GA" conf="test->runtime"/>
@@ -55,4 +61,4 @@
</dependencies>
</ivy-module>
</ivy-module>

View File

@@ -84,13 +84,13 @@
<dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>${jsf.version}</version>
<version>2.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>${jsf.version}</version>
<version>2.0.2</version>
<scope>provided</scope>
</dependency>
</dependencies>
@@ -114,6 +114,5 @@
</repositories>
<properties>
<spring.version>3.0.2.RELEASE</spring.version>
<jsf.version>1.2_09</jsf.version>
</properties>
</project>

View File

@@ -0,0 +1,178 @@
/*
* 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.ui;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import javax.faces.component.UIComponent;
import javax.faces.component.UIViewRoot;
import javax.faces.component.behavior.ClientBehavior;
import javax.faces.component.visit.VisitCallback;
import javax.faces.component.visit.VisitContext;
import javax.faces.context.FacesContext;
import javax.faces.event.AbortProcessingException;
import javax.faces.event.ComponentSystemEvent;
import javax.faces.event.ComponentSystemEventListener;
import javax.faces.event.PhaseId;
import javax.faces.event.SystemEventListener;
import org.springframework.faces.webflow.JsfVersion;
/**
* <p>
* A subclass of AjaxViewRoot for use with JSF 2.0.
* </p>
*
* <p>
* Note that these methods should ideally be in DelegatingViewRoot.java. However, due to some introspection done by the
* JSF runtime that would make it impossible to use in JSF 1.2 because some of the delegate methods contain JSF 2.0
* specific types and cause ClassNotFoundExceptions.
* </p>
*
* @author Phil Webb
*/
public class AjaxJsf2ViewRoot extends AjaxViewRoot {
public AjaxJsf2ViewRoot(UIViewRoot original) {
super(original);
if (JsfVersion.isAtLeastJsf20()) {
setId(createUniqueId());
}
}
public void addClientBehavior(String eventName, ClientBehavior behavior) {
getOriginalViewRoot().addClientBehavior(eventName, behavior);
}
public void addComponentResource(FacesContext context, UIComponent componentResource) {
getOriginalViewRoot().addComponentResource(context, componentResource);
}
public void addComponentResource(FacesContext context, UIComponent componentResource, String target) {
getOriginalViewRoot().addComponentResource(context, componentResource, target);
}
public void broadcastEvents(FacesContext context, PhaseId phaseId) {
getOriginalViewRoot().broadcastEvents(context, phaseId);
}
public void clearInitialState() {
getOriginalViewRoot().clearInitialState();
}
public String createUniqueId(FacesContext context, String seed) {
return getOriginalViewRoot().createUniqueId(context, seed);
}
public Map getClientBehaviors() {
return getOriginalViewRoot().getClientBehaviors();
}
public String getClientId() {
return getOriginalViewRoot().getClientId();
}
public List getComponentResources(FacesContext context, String target) {
return getOriginalViewRoot().getComponentResources(context, target);
}
public String getDefaultEventName() {
return getOriginalViewRoot().getDefaultEventName();
}
public Collection getEventNames() {
return getOriginalViewRoot().getEventNames();
}
public List getListenersForEventClass(Class eventClass) {
return getOriginalViewRoot().getListenersForEventClass(eventClass);
}
public UIComponent getNamingContainer() {
return getOriginalViewRoot().getNamingContainer();
}
public List getPhaseListeners() {
return getOriginalViewRoot().getPhaseListeners();
}
public Map getResourceBundleMap() {
return getOriginalViewRoot().getResourceBundleMap();
}
public List getViewListenersForEventClass(Class systemEvent) {
return getOriginalViewRoot().getViewListenersForEventClass(systemEvent);
}
public Map getViewMap() {
return getOriginalViewRoot().getViewMap();
}
public Map getViewMap(boolean create) {
return getOriginalViewRoot().getViewMap(create);
}
public boolean initialStateMarked() {
return getOriginalViewRoot().initialStateMarked();
}
public void markInitialState() {
getOriginalViewRoot().markInitialState();
}
public boolean isInView() {
return getOriginalViewRoot().isInView();
}
public void processEvent(ComponentSystemEvent event) throws AbortProcessingException {
getOriginalViewRoot().processEvent(event);
}
public void removeComponentResource(FacesContext context, UIComponent componentResource) {
getOriginalViewRoot().removeComponentResource(context, componentResource);
}
public void removeComponentResource(FacesContext context, UIComponent componentResource, String target) {
getOriginalViewRoot().removeComponentResource(context, componentResource, target);
}
public void setInView(boolean isInView) {
getOriginalViewRoot().setInView(isInView);
}
public void subscribeToEvent(Class eventClass, ComponentSystemEventListener componentListener) {
getOriginalViewRoot().subscribeToEvent(eventClass, componentListener);
}
public void subscribeToViewEvent(Class systemEvent, SystemEventListener listener) {
getOriginalViewRoot().subscribeToViewEvent(systemEvent, listener);
}
public void unsubscribeFromEvent(Class eventClass, ComponentSystemEventListener componentListener) {
getOriginalViewRoot().unsubscribeFromEvent(eventClass, componentListener);
}
public void unsubscribeFromViewEvent(Class systemEvent, SystemEventListener listener) {
getOriginalViewRoot().unsubscribeFromViewEvent(systemEvent, listener);
}
public boolean visitTree(VisitContext context, VisitCallback callback) {
return getOriginalViewRoot().visitTree(context, callback);
}
}

View File

@@ -71,7 +71,7 @@ public abstract class DelegatingViewRoot extends UIViewRoot {
* @see javax.faces.component.UIViewRoot#createUniqueId()
*/
public String createUniqueId() {
return original.createUniqueId();
return (original != null) ? original.createUniqueId() : null;
}
/**
@@ -409,7 +409,10 @@ public abstract class DelegatingViewRoot extends UIViewRoot {
* @see javax.faces.component.UIComponentBase#setId(java.lang.String)
*/
public void setId(String id) {
original.setId(id);
// Test for null to deal with JSF setId on constructor
if (original != null) {
original.setId(id);
}
}
/**

View File

@@ -2,7 +2,9 @@ package org.springframework.faces.webflow;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.io.Writer;
import java.net.MalformedURLException;
import java.net.URL;
import java.security.Principal;
@@ -12,6 +14,7 @@ import java.util.Map;
import java.util.Set;
import javax.faces.context.ExternalContext;
import javax.faces.context.Flash;
class ExternalContextWrapper extends ExternalContext {
@@ -188,4 +191,111 @@ class ExternalContextWrapper extends ExternalContext {
public void setResponseCharacterEncoding(String encoding) {
delegate.setResponseCharacterEncoding(encoding);
}
// --------------- JSF 2.0 Pass-through delegate methods ------------------//
public String getContextName() {
return delegate.getContextName();
}
public void addResponseCookie(String name, String value, Map properties) {
delegate.addResponseCookie(name, value, properties);
}
public Flash getFlash() {
return delegate.getFlash();
}
public String getMimeType(String file) {
return delegate.getMimeType(file);
}
public String getRequestScheme() {
return delegate.getRequestScheme();
}
public String getRequestServerName() {
return delegate.getRequestServerName();
}
public int getRequestServerPort() {
return delegate.getRequestServerPort();
}
public String getRealPath(String path) {
return delegate.getRealPath(path);
}
public int getRequestContentLength() {
return delegate.getRequestContentLength();
}
public OutputStream getResponseOutputStream() throws IOException {
return delegate.getResponseOutputStream();
}
public Writer getResponseOutputWriter() throws IOException {
return delegate.getResponseOutputWriter();
}
public void setResponseContentType(String contentType) {
delegate.setResponseContentType(contentType);
}
public void invalidateSession() {
delegate.invalidateSession();
}
public void setResponseHeader(String name, String value) {
delegate.setResponseHeader(name, value);
}
public void addResponseHeader(String name, String value) {
delegate.addResponseHeader(name, value);
}
public void setResponseBufferSize(int size) {
delegate.setResponseBufferSize(size);
}
public int getResponseBufferSize() {
return delegate.getResponseBufferSize();
}
public boolean isResponseCommitted() {
return delegate.isResponseCommitted();
}
public void responseReset() {
delegate.responseReset();
}
public void responseSendError(int statusCode, String message) throws IOException {
delegate.responseSendError(statusCode, message);
}
public void setResponseStatus(int statusCode) {
delegate.setResponseStatus(statusCode);
}
public void responseFlushBuffer() throws IOException {
delegate.responseFlushBuffer();
}
public void setResponseContentLength(int length) {
delegate.setResponseContentLength(length);
}
public String encodeBookmarkableURL(String baseUrl, Map parameters) {
return delegate.encodeBookmarkableURL(baseUrl, parameters);
}
public String encodeRedirectURL(String baseUrl, Map parameters) {
return delegate.encodeRedirectURL(baseUrl, parameters);
}
public String encodePartialActionURL(String url) {
return delegate.encodePartialActionURL(url);
}
}

View File

@@ -48,4 +48,8 @@ public class FlowApplicationFactory extends ApplicationFactory {
delegate.setApplication(application);
}
public ApplicationFactory getWrapped() {
return delegate;
}
}

View File

@@ -17,17 +17,23 @@ package org.springframework.faces.webflow;
import java.lang.reflect.Method;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import javax.el.ELContext;
import javax.faces.FactoryFinder;
import javax.faces.application.Application;
import javax.faces.application.FacesMessage;
import javax.faces.application.ProjectStage;
import javax.faces.component.UIViewRoot;
import javax.faces.context.ExceptionHandler;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.faces.context.FacesContextFactory;
import javax.faces.context.PartialViewContext;
import javax.faces.context.ResponseStream;
import javax.faces.context.ResponseWriter;
import javax.faces.event.PhaseId;
import javax.faces.lifecycle.Lifecycle;
import javax.faces.render.RenderKit;
@@ -199,6 +205,64 @@ public class FlowFacesContext extends FacesContext {
return delegate;
}
// --------------- JSF 2.0 Pass-through delegate methods ------------------//
public Map getAttributes() {
return delegate.getAttributes();
}
public PartialViewContext getPartialViewContext() {
return delegate.getPartialViewContext();
}
public List getMessageList() {
return delegate.getMessageList();
}
public List getMessageList(String clientId) {
return delegate.getMessageList(clientId);
}
public boolean isPostback() {
return delegate.isPostback();
}
public PhaseId getCurrentPhaseId() {
return delegate.getCurrentPhaseId();
}
public void setCurrentPhaseId(PhaseId currentPhaseId) {
delegate.setCurrentPhaseId(currentPhaseId);
}
public ExceptionHandler getExceptionHandler() {
return delegate.getExceptionHandler();
}
public boolean isProcessingEvents() {
return delegate.isProcessingEvents();
}
public boolean isProjectStage(ProjectStage stage) {
return delegate.isProjectStage(stage);
}
public boolean isValidationFailed() {
return delegate.isValidationFailed();
}
public void setExceptionHandler(ExceptionHandler exceptionHandler) {
delegate.setExceptionHandler(exceptionHandler);
}
public void setProcessingEvents(boolean processingEvents) {
delegate.setProcessingEvents(processingEvents);
}
public void validationFailed() {
delegate.validationFailed();
}
// ------------------ Private helper methods ----------------------//
private class FlowExternalContext extends ExternalContextWrapper {

View File

@@ -156,6 +156,7 @@ public class FlowViewStateManager extends StateManager {
}
UIViewRoot viewRoot = restoreTreeStructure(context, viewId, renderKitId);
if (viewRoot != null) {
context.setViewRoot(viewRoot);
restoreComponentState(context, viewRoot, renderKitId);
}
return viewRoot;

View File

@@ -21,7 +21,6 @@ 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;
/**
@@ -31,18 +30,6 @@ 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++) {
@@ -80,7 +67,7 @@ public class JsfUtils {
}
public static boolean isAtLeastJsf12() {
return JSF_12;
return JsfVersion.isAtLeastJsf12();
}
public static boolean isPortlet(FacesContext context) {

View File

@@ -0,0 +1,68 @@
/*
* 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 javax.faces.context.FacesContext;
import org.springframework.util.ReflectionUtils;
/**
* Internal helper class to find the version of JSF in use at runtime.
*
* @author Phil Webb
*/
public class JsfVersion {
/**
* JSF Version 1.1
*/
public static final int JSF_11 = 0;
/**
* JSF Version 1.2
*/
public static final int JSF_12 = 1;
/**
* JSF Version 2.0
*/
public static final int JSF_20 = 2;
private static final int jsfVersion;
static {
if (ReflectionUtils.findMethod(FacesContext.class, "isPostback") != null) {
jsfVersion = JsfVersion.JSF_20;
} else if (ReflectionUtils.findMethod(FacesContext.class, "getELContext") != null) {
jsfVersion = JsfVersion.JSF_12;
} else {
jsfVersion = JsfVersion.JSF_11;
}
}
public static int getJsfVersion() {
return jsfVersion;
}
public static boolean isAtLeastJsf20() {
return jsfVersion >= JSF_20;
}
public static boolean isAtLeastJsf12() {
return jsfVersion >= JSF_12;
}
}

View File

@@ -32,6 +32,7 @@ import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.binding.expression.Expression;
import org.springframework.faces.ui.AjaxJsf2ViewRoot;
import org.springframework.faces.ui.AjaxViewRoot;
import org.springframework.js.ajax.SpringJavascriptAjaxHandler;
import org.springframework.webflow.context.ExternalContext;
@@ -136,7 +137,8 @@ public class JsfViewFactory implements ViewFactory {
private JsfView createJsfView(UIViewRoot root, Lifecycle lifecycle, RequestContext context) {
if (isSpringJavascriptAjaxRequest(context.getExternalContext())) {
return new JsfView(new AjaxViewRoot(root), lifecycle, context);
AjaxViewRoot viewRoot = (JsfVersion.isAtLeastJsf20()) ? new AjaxJsf2ViewRoot(root) : new AjaxViewRoot(root);
return new JsfView(viewRoot, lifecycle, context);
} else {
return new JsfView(root, lifecycle, context);
}

View File

@@ -12,14 +12,20 @@ import javax.faces.event.AbortProcessingException;
import javax.faces.event.ActionEvent;
import javax.faces.event.ActionListener;
import junit.framework.TestCase;
import org.springframework.faces.webflow.JSFMockHelper;
import org.springframework.util.ReflectionUtils;
import com.sun.facelets.component.UIRepeat;
import junit.framework.TestCase;
public class SelectionTrackingActionListenerTests extends TestCase {
/**
* JSF Mock Helper
*/
private JSFMockHelper jsfMockHelper = new JSFMockHelper();
/**
* The JSF view to simulate
*/
@@ -40,7 +46,8 @@ public class SelectionTrackingActionListenerTests extends TestCase {
*/
private ActionListener selectionTrackingListener = new SelectionTrackingActionListener(delegateListener);
public void setUp() {
public void setUp() throws Exception {
jsfMockHelper.setUp();
viewToTest = new UIViewRoot();
List rows = new ArrayList();
rows.add(new TestRowData());
@@ -49,6 +56,10 @@ public class SelectionTrackingActionListenerTests extends TestCase {
dataModel = new OneSelectionTrackingListDataModel(rows);
}
protected void tearDown() throws Exception {
jsfMockHelper.tearDown();
}
public void testProcessActionWithUIData() {
UIData dataTable = new UIData();

View File

@@ -10,7 +10,7 @@ import javax.faces.render.RenderKitFactory;
import junit.framework.TestCase;
import org.apache.shale.test.mock.MockResponseWriter;
import org.apache.myfaces.test.mock.MockResponseWriter;
import org.springframework.faces.webflow.JSFMockHelper;
import org.springframework.faces.webflow.MockViewHandler;
import org.springframework.util.StringUtils;

View File

@@ -7,7 +7,7 @@ import javax.faces.component.UIParameter;
import junit.framework.TestCase;
import org.apache.shale.test.mock.MockResponseWriter;
import org.apache.myfaces.test.mock.MockResponseWriter;
import org.springframework.faces.webflow.JSFMockHelper;
public class ProgressiveCommandLinkRendererTests extends TestCase {

View File

@@ -5,7 +5,7 @@ import java.io.StringWriter;
import junit.framework.TestCase;
import org.apache.shale.test.mock.MockResponseWriter;
import org.apache.myfaces.test.mock.MockResponseWriter;
import org.springframework.faces.webflow.JSFMockHelper;
public class FlowResourceHelperTests extends TestCase {

View File

@@ -1,30 +1,37 @@
package org.springframework.faces.webflow;
import java.net.URL;
import java.net.URLClassLoader;
import javax.faces.FactoryFinder;
import javax.faces.application.Application;
import javax.faces.application.ApplicationFactory;
import javax.faces.component.UIViewRoot;
import javax.faces.context.FacesContext;
import javax.faces.context.FacesContextFactory;
import javax.faces.lifecycle.LifecycleFactory;
import javax.faces.render.RenderKitFactory;
import org.apache.shale.test.base.AbstractJsfTestCase;
import org.apache.shale.test.mock.MockApplication;
import org.apache.shale.test.mock.MockExternalContext;
import org.apache.shale.test.mock.MockHttpServletRequest;
import org.apache.shale.test.mock.MockHttpServletResponse;
import org.apache.shale.test.mock.MockHttpSession;
import org.apache.shale.test.mock.MockLifecycle;
import org.apache.shale.test.mock.MockLifecycleFactory;
import org.apache.shale.test.mock.MockRenderKit;
import org.apache.shale.test.mock.MockServletConfig;
import org.apache.shale.test.mock.MockServletContext;
import org.apache.myfaces.test.base.AbstractJsfTestCase;
import org.apache.myfaces.test.mock.MockApplicationFactory;
import org.apache.myfaces.test.mock.MockExternalContext;
import org.apache.myfaces.test.mock.MockHttpServletRequest;
import org.apache.myfaces.test.mock.MockHttpServletResponse;
import org.apache.myfaces.test.mock.MockHttpSession;
import org.apache.myfaces.test.mock.MockPartialViewContextFactory;
import org.apache.myfaces.test.mock.MockRenderKit;
import org.apache.myfaces.test.mock.MockRenderKitFactory;
import org.apache.myfaces.test.mock.MockServletConfig;
import org.apache.myfaces.test.mock.MockServletContext;
import org.apache.myfaces.test.mock.lifecycle.MockLifecycle;
import org.apache.myfaces.test.mock.lifecycle.MockLifecycleFactory;
/**
* Helper for using the mock JSF environment provided by shale-test inside unit tests that do not extend
* {@link AbstractJsfTestCase}
* @author Jeremy Grelle
*
* @author Jeremy Grelle
* @author Phil Webb
*/
public class JSFMockHelper {
@@ -88,17 +95,21 @@ public class JSFMockHelper {
private static class JSFMock extends AbstractJsfTestCase {
private ClassLoader threadContextClassLoader;
public JSFMock() {
super("JSFMock");
}
FacesContextFactory facesContextFactory;
FacesContext facesContext;
FacesContextFactory facesContextFactory;
public void setUp() throws Exception {
// Thread.currentThread().setContextClassLoader(
// new URLClassLoader(new URL[0], this.getClass().getClassLoader()));
// Set up a new thread context class loader
threadContextClassLoader = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(
new URLClassLoader(new URL[0], this.getClass().getClassLoader()));
// Set up Servlet API Objects
servletContext = new MockServletContext();
@@ -110,20 +121,12 @@ public class JSFMockHelper {
response = new MockHttpServletResponse();
// Set up JSF API Objects
FactoryFinder.setFactory(FactoryFinder.APPLICATION_FACTORY,
"org.apache.shale.test.mock.MockApplicationFactory");
FactoryFinder.setFactory(FactoryFinder.FACES_CONTEXT_FACTORY,
"org.springframework.faces.webflow.MockBaseFacesContextFactory");
/*
* FactoryFinder.setFactory(FactoryFinder.FACES_CONTEXT_FACTORY,
* "org.apache.shale.test.mock.MockFacesContextFactory");
*/
FactoryFinder
.setFactory(FactoryFinder.LIFECYCLE_FACTORY, "org.apache.shale.test.mock.MockLifecycleFactory");
FactoryFinder.setFactory(FactoryFinder.RENDER_KIT_FACTORY,
"org.apache.shale.test.mock.MockRenderKitFactory");
application = new MockApplication();
FactoryFinder.setFactory(FactoryFinder.APPLICATION_FACTORY, MockApplicationFactory.class.getName());
FactoryFinder.setFactory(FactoryFinder.FACES_CONTEXT_FACTORY, MockBaseFacesContextFactory.class.getName());
FactoryFinder.setFactory(FactoryFinder.LIFECYCLE_FACTORY, MockLifecycleFactory.class.getName());
FactoryFinder.setFactory(FactoryFinder.RENDER_KIT_FACTORY, MockRenderKitFactory.class.getName());
FactoryFinder.setFactory(FactoryFinder.PARTIAL_VIEW_CONTEXT_FACTORY, MockPartialViewContextFactory.class
.getName());
externalContext = new MockExternalContext(servletContext, request, response);
lifecycleFactory = (MockLifecycleFactory) FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
lifecycle = (MockLifecycle) lifecycleFactory.getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE);
@@ -134,6 +137,9 @@ public class JSFMockHelper {
root.setViewId("/viewId");
root.setRenderKitId(RenderKitFactory.HTML_BASIC_RENDER_KIT);
facesContext.setViewRoot(root);
ApplicationFactory applicationFactory = (ApplicationFactory) FactoryFinder
.getFactory(FactoryFinder.APPLICATION_FACTORY);
application = (org.apache.myfaces.test.mock.MockApplication) applicationFactory.getApplication();
RenderKitFactory renderKitFactory = (RenderKitFactory) FactoryFinder
.getFactory(FactoryFinder.RENDER_KIT_FACTORY);
renderKit = new MockRenderKit();
@@ -157,9 +163,11 @@ public class JSFMockHelper {
session = null;
FactoryFinder.releaseFactories();
Thread.currentThread().setContextClassLoader(threadContextClassLoader);
threadContextClassLoader = null;
}
public MockApplication application() {
public org.apache.myfaces.test.mock.MockApplication application() {
return application;
}

View File

@@ -14,8 +14,8 @@ import javax.faces.lifecycle.Lifecycle;
import junit.framework.TestCase;
import org.apache.shale.test.mock.MockResponseWriter;
import org.apache.shale.test.mock.MockStateManager;
import org.apache.myfaces.test.mock.MockResponseWriter;
import org.apache.myfaces.test.mock.MockStateManager;
import org.easymock.EasyMock;
import org.springframework.faces.ui.AjaxViewRoot;
import org.springframework.webflow.core.collection.MutableAttributeMap;
@@ -130,7 +130,7 @@ public class JsfViewTests extends TestCase {
try {
view.render();
} catch (FacesException ex) {
} catch (Exception ex) {
assertNull("The FacesContext was not released", FacesContext.getCurrentInstance());
}
}

View File

@@ -1,14 +1,16 @@
package org.springframework.faces.webflow;
import java.util.Map;
import javax.faces.FactoryFinder;
import javax.faces.application.Application;
import javax.faces.application.ApplicationFactory;
import javax.faces.context.ExternalContext;
import javax.faces.lifecycle.Lifecycle;
import org.apache.shale.test.mock.MockFacesContext12;
import org.apache.myfaces.test.mock.MockFacesContext20;
public class MockBaseFacesContext extends MockFacesContext12 {
public class MockBaseFacesContext extends MockFacesContext20 {
private Application application;
@@ -24,6 +26,10 @@ public class MockBaseFacesContext extends MockFacesContext12 {
super(externalContext, lifecycle);
}
public Map getAttributes() {
return super.getAttributes();
}
public Application getApplication() {
if (application == null) {
ApplicationFactory applicationFactory = (ApplicationFactory) FactoryFinder

View File

@@ -9,7 +9,7 @@ import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.shale.test.mock.MockExternalContext;
import org.apache.myfaces.test.mock.MockExternalContext;
public class MockBaseFacesContextFactory extends FacesContextFactory {

View File

@@ -13,7 +13,7 @@ Import-Template:
javax.el;version="[1.0.0, 2.0.0)",
javax.servlet;version="[2.4.0, 3.0.0)",
javax.servlet.http;version="[2.4.0, 3.0.0)",
javax.faces.*;version="[1.2.0, 2.0.0)",
javax.faces.*;version="[1.2.0, 3.0.0)",
org.ajax4jsf.*;version="[1.1.1, 2.0.0)";resolution:=optional,
com.sun.facelets.*;version="[1.1.0, 2.0.0)";resolution:=optional,
org.w3c.dom;version="0"

View File

@@ -4,10 +4,12 @@
<property name="source.version" value="1.5"/>
<property name="ivy.cache.dir" value="${basedir}/../../ivy-cache"/>
<property name="integration.repo.dir" value="${basedir}/../../integration-repo"/>
<property name="ivy.settings.file" value="${basedir}/../../build-spring-webflow/ivysettings.xml"/>
<property file="${basedir}/../../build.properties"/>
<import file="${basedir}/../../spring-build/war/default.xml"/>
<target name="publish"/>
<target name="publish"/>
<target name="publish-maven-central"/>

View File

@@ -46,7 +46,7 @@
<dependency org="org.springframework.security" name="org.springframework.security.core" rev="3.0.2.RELEASE" conf="compile->runtime"/>
<dependency org="org.springframework.security" name="org.springframework.security.config" rev="3.0.2.RELEASE" conf="compile->runtime"/>
<dependency org="org.springframework.security" name="org.springframework.security.web" rev="3.0.2.RELEASE" conf="compile->runtime"/>
<dependency org="org.springframework.webflow" name="org.springframework.faces" rev="latest.integration" conf="compile->jsf12"/>
<dependency org="org.springframework.webflow" name="org.springframework.faces" rev="latest.integration" conf="compile->jsf20"/>
<dependency org="org.springframework.webflow" name="org.springframework.js" rev="latest.integration" conf="compile->runtime"/>
<dependency org="org.springframework.webflow" name="org.springframework.webflow" rev="latest.integration" conf="compile->runtime"/>
@@ -57,4 +57,4 @@
</dependencies>
</ivy-module>
</ivy-module>

View File

@@ -26,7 +26,7 @@
<!-- Causes Facelets to refresh templates during development -->
<context-param>
<param-name>facelets.REFRESH_PERIOD</param-name>
<param-name>javax.faces.FACELETS_REFRESH_PERIOD</param-name>
<param-value>1</param-value>
</context-param>
@@ -59,7 +59,18 @@
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- Sun JSF initialization listener. -->
<listener>
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>
<!-- Appache MyFaces JSF initialization listener --><!--
<listener>
<listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
</listener>
-->
<!-- Loads the Spring web application context -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>

View File

@@ -4,10 +4,11 @@
<property name="source.version" value="1.5"/>
<property name="ivy.cache.dir" value="${basedir}/../../ivy-cache"/>
<property name="integration.repo.dir" value="${basedir}/../../integration-repo"/>
<property name="ivy.settings.file" value="${basedir}/../../build-spring-webflow/ivysettings.xml"/>
<property file="${basedir}/../../build.properties"/>
<import file="${basedir}/../../spring-build/war/default.xml"/>
<target name="publish"/>
<target name="publish"/>
<target name="publish-maven-central"/>

View File

@@ -4,6 +4,7 @@
<property name="source.version" value="1.5"/>
<property name="ivy.cache.dir" value="${basedir}/../../ivy-cache"/>
<property name="integration.repo.dir" value="${basedir}/../../integration-repo"/>
<property name="ivy.settings.file" value="${basedir}/../../build-spring-webflow/ivysettings.xml"/>
<property file="${basedir}/../../build.properties"/>
<import file="${basedir}/../../spring-build/war/default.xml"/>

View File

@@ -4,6 +4,7 @@
<property name="source.version" value="1.5"/>
<property name="ivy.cache.dir" value="${basedir}/../../ivy-cache"/>
<property name="integration.repo.dir" value="${basedir}/../../integration-repo"/>
<property name="ivy.settings.file" value="${basedir}/../../build-spring-webflow/ivysettings.xml"/>
<property file="${basedir}/../../build.properties"/>
<import file="${basedir}/../../spring-build/war/default.xml"/>

View File

@@ -4,6 +4,7 @@
<property name="source.version" value="1.5"/>
<property name="ivy.cache.dir" value="${basedir}/../../ivy-cache"/>
<property name="integration.repo.dir" value="${basedir}/../../integration-repo"/>
<property name="ivy.settings.file" value="${basedir}/../../build-spring-webflow/ivysettings.xml"/>
<property file="${basedir}/../../build.properties"/>
<import file="${basedir}/../../spring-build/war/default.xml"/>

View File

@@ -23,8 +23,8 @@
<!-- core dependencies -->
<dependency org="com.sun.facelets" name="com.springsource.com.sun.facelets" rev="1.1.14" conf="compile->runtime"/>
<dependency org="javax.el" name="com.springsource.javax.el" rev="1.0.0" conf="provided->runtime"/>
<dependency org="com.sun.faces" name="com.springsource.com.sun.faces" rev="1.2.0.09" conf="compile->runtime" />
<dependency org="javax.faces" name="com.springsource.javax.faces" rev="1.2.0.09" conf="compile->runtime" />
<dependency org="javax.faces" name="jsf-api" rev="2.0" conf="compile->runtime" />
<dependency org="com.sun.faces" name="jsf-impl" rev="2.0.2" conf="compile->runtime" />
<dependency org="javax.persistence" name="com.springsource.javax.persistence" rev="1.0.0" conf="compile->runtime"/>
<dependency org="javax.servlet" name="com.springsource.javax.servlet" rev="2.4.0" conf="provided->runtime"/>
<dependency org="javax.servlet" name="com.springsource.javax.servlet.jsp.jstl" rev="1.1.2" conf="compile->runtime"/>

View File

@@ -25,10 +25,22 @@
<!-- Causes Facelets to refresh templates during development -->
<context-param>
<param-name>facelets.REFRESH_PERIOD</param-name>
<param-name>javax.faces.FACELETS_REFRESH_PERIOD</param-name>
<param-value>1</param-value>
</context-param>
<!-- Sun JSF initialization listener. -->
<listener>
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>
<!-- Appache MyFaces JSF initialization listener --><!--
<listener>
<listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
</listener>
-->
<!-- Loads the Spring web application context -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>