Skip to content

Commit d5b9b26

Browse files
committed
extended coverage of JSF 2.0 implicit attributes: "viewScope", "flash", "resource"
1 parent cac42ef commit d5b9b26

File tree

1 file changed

+29
-3
lines changed

1 file changed

+29
-3
lines changed

org.springframework.web/src/main/java/org/springframework/web/context/request/FacesRequestAttributes.java

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2009 the original author or authors.
2+
* Copyright 2002-2011 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -18,6 +18,8 @@
1818

1919
import java.lang.reflect.Method;
2020
import java.util.Map;
21+
import javax.faces.application.Application;
22+
import javax.faces.component.UIViewRoot;
2123
import javax.faces.context.ExternalContext;
2224
import javax.faces.context.FacesContext;
2325
import javax.portlet.PortletSession;
@@ -166,6 +168,9 @@ else if ("sessionScope".equals(key)) {
166168
else if ("applicationScope".equals(key)) {
167169
return getExternalContext().getApplicationMap();
168170
}
171+
else if ("facesContext".equals(key)) {
172+
return getFacesContext();
173+
}
169174
else if ("cookie".equals(key)) {
170175
return getExternalContext().getRequestCookieMap();
171176
}
@@ -187,8 +192,29 @@ else if ("initParam".equals(key)) {
187192
else if ("view".equals(key)) {
188193
return getFacesContext().getViewRoot();
189194
}
190-
else if ("facesContext".equals(key)) {
191-
return getFacesContext();
195+
else if ("viewScope".equals(key)) {
196+
try {
197+
return ReflectionUtils.invokeMethod(UIViewRoot.class.getMethod("getViewMap"), getFacesContext().getViewRoot());
198+
}
199+
catch (NoSuchMethodException ex) {
200+
throw new IllegalStateException("JSF 2.0 API not available", ex);
201+
}
202+
}
203+
else if ("flash".equals(key)) {
204+
try {
205+
return ReflectionUtils.invokeMethod(ExternalContext.class.getMethod("getFlash"), getExternalContext());
206+
}
207+
catch (NoSuchMethodException ex) {
208+
throw new IllegalStateException("JSF 2.0 API not available", ex);
209+
}
210+
}
211+
else if ("resource".equals(key)) {
212+
try {
213+
return ReflectionUtils.invokeMethod(Application.class.getMethod("getResourceHandler"), getFacesContext().getApplication());
214+
}
215+
catch (NoSuchMethodException ex) {
216+
throw new IllegalStateException("JSF 2.0 API not available", ex);
217+
}
192218
}
193219
else {
194220
return null;

0 commit comments

Comments
 (0)