diff --git a/build.gradle b/build.gradle index 49b6972094..ccad575417 100644 --- a/build.gradle +++ b/build.gradle @@ -542,7 +542,7 @@ project("spring-web") { optional(project(":spring-oxm")) // for MarshallingHttpMessageConverter compile("aopalliance:aopalliance:1.0") provided("javax.el:javax.el-api:2.2.4") - provided("com.sun.faces:jsf-api:2.1.7") + provided("javax.faces:javax.faces-api:2.2") provided("javax.portlet:portlet-api:2.0") provided("javax.servlet:javax.servlet-api:3.0.1") provided("javax.servlet.jsp:jsp-api:2.1") diff --git a/spring-web/src/main/java/org/springframework/web/context/request/FacesRequestAttributes.java b/spring-web/src/main/java/org/springframework/web/context/request/FacesRequestAttributes.java index 32f4585234..3c3f6437eb 100644 --- a/spring-web/src/main/java/org/springframework/web/context/request/FacesRequestAttributes.java +++ b/spring-web/src/main/java/org/springframework/web/context/request/FacesRequestAttributes.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2013 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. @@ -18,8 +18,6 @@ package org.springframework.web.context.request; import java.lang.reflect.Method; import java.util.Map; -import javax.faces.application.Application; -import javax.faces.component.UIViewRoot; import javax.faces.context.ExternalContext; import javax.faces.context.FacesContext; import javax.portlet.PortletSession; @@ -43,6 +41,8 @@ import org.springframework.web.util.WebUtils; * callbacks, consider defining a Spring {@link RequestContextListener} in your * {@code web.xml}. * + *

Requires JSF 2.0 or higher, as of Spring 4.0. + * * @author Juergen Hoeller * @since 2.5.2 * @see javax.faces.context.FacesContext#getExternalContext() @@ -199,28 +199,13 @@ public class FacesRequestAttributes implements RequestAttributes { return getFacesContext().getViewRoot(); } else if ("viewScope".equals(key)) { - try { - return ReflectionUtils.invokeMethod(UIViewRoot.class.getMethod("getViewMap"), getFacesContext().getViewRoot()); - } - catch (NoSuchMethodException ex) { - throw new IllegalStateException("JSF 2.0 API not available", ex); - } + return getFacesContext().getViewRoot().getViewMap(); } else if ("flash".equals(key)) { - try { - return ReflectionUtils.invokeMethod(ExternalContext.class.getMethod("getFlash"), getExternalContext()); - } - catch (NoSuchMethodException ex) { - throw new IllegalStateException("JSF 2.0 API not available", ex); - } + return getExternalContext().getFlash(); } else if ("resource".equals(key)) { - try { - return ReflectionUtils.invokeMethod(Application.class.getMethod("getResourceHandler"), getFacesContext().getApplication()); - } - catch (NoSuchMethodException ex) { - throw new IllegalStateException("JSF 2.0 API not available", ex); - } + return getFacesContext().getApplication().getResourceHandler(); } else { return null; diff --git a/spring-web/src/main/java/org/springframework/web/context/request/FacesWebRequest.java b/spring-web/src/main/java/org/springframework/web/context/request/FacesWebRequest.java index 940e0c9d0a..18983a14cf 100644 --- a/spring-web/src/main/java/org/springframework/web/context/request/FacesWebRequest.java +++ b/spring-web/src/main/java/org/springframework/web/context/request/FacesWebRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2013 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. @@ -28,6 +28,8 @@ import org.springframework.util.StringUtils; /** * {@link WebRequest} adapter for a JSF {@link javax.faces.context.FacesContext}. * + *

Requires JSF 2.0 or higher, as of Spring 4.0. + * * @author Juergen Hoeller * @since 2.5.2 */