I'm trying to access a View's attributes from a JSF component. I have two pages that share a third with in included as a subView, and I'd like to hide a few fields depending on which page is including it. To accomplish this, I set an attribute on the main View, and try to read it from a subView component.
For example:
Page 1:
<f:view>
<f:attribute name="hideZipCode" value="true" />
Include page:
<h:outputLabel value="Zip Code" rendered="#{facesContext.viewRoot.attributes.containsKey('hideZipCode')}" /> |
I get the following error:
javax.servlet.ServletException: Class javax.el.BeanELResolver can not access a member of class javax.faces.component.UIComponentBase$AttributesMap with modifiers "public"
root cause
java.lang.IllegalAccessException: Class javax.el.BeanELResolver can not access a member of class javax.faces.component.UIComponentBase$AttributesMap with modifiers "public"
How can the view attributes be accessed from a component?
How about using a f:viewParam and putting the value in a managed bean?