Skip to content

Commit

Permalink
extended coverage of JSF 2.0 implicit attributes: "viewScope", "flash…
Browse files Browse the repository at this point in the history
…", "resource"
  • Loading branch information
jhoeller committed Jun 8, 2011
1 parent cac42ef commit d5b9b26
Showing 1 changed file with 29 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2009 the original author or authors.
* Copyright 2002-2011 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.
Expand All @@ -18,6 +18,8 @@

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;
Expand Down Expand Up @@ -166,6 +168,9 @@ else if ("sessionScope".equals(key)) {
else if ("applicationScope".equals(key)) {
return getExternalContext().getApplicationMap();
}
else if ("facesContext".equals(key)) {
return getFacesContext();
}
else if ("cookie".equals(key)) {
return getExternalContext().getRequestCookieMap();
}
Expand All @@ -187,8 +192,29 @@ else if ("initParam".equals(key)) {
else if ("view".equals(key)) {
return getFacesContext().getViewRoot();
}
else if ("facesContext".equals(key)) {
return getFacesContext();
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);
}
}
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);
}
}
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);
}
}
else {
return null;
Expand Down

0 comments on commit d5b9b26

Please sign in to comment.