[ https://issues.apache.org/jira/browse/MYFACES-3283?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Matt Benson resolved MYFACES-3283. ---------------------------------- Resolution: Invalid In cases where you rely on the component stack in this manner you can query this information in the context of a tree visit (I personally have gotten into the habit of doing nearly everything in a tree visit for this reason). > #{cc.attr} attributes fail when a child component is accessed outside of the > composite component (i.e. in action listeners or other events) > ------------------------------------------------------------------------------------------------------------------------------------------- > > Key: MYFACES-3283 > URL: https://issues.apache.org/jira/browse/MYFACES-3283 > Project: MyFaces Core > Issue Type: Bug > Components: General > Affects Versions: 2.0.7 > Environment: Mac OS 10.6, Tomcat 7 > Reporter: Kito D. Mann > Attachments: myfaces_cc_issue.war > > > If you reference a property of child component anywhere outside of the > composite's context (i.e. in an action method, a component system event > listener, etc.), the property will not be evaluated properly if the > expression is a composite component attribute (i.e. "#{cc.attrs.property}"). > This is because the EL evaluation code can't find the parent composite > component. > For example, consider the composite component: > <?xml version="1.0"?> > <html xmlns="http://www.w3.org/1999/xhtml" > xmlns:h="http://java.sun.com/jsf/html" > xmlns:composite="http://java.sun.com/jsf/composite"> > <composite:interface> > <composite:attribute name="label" /> > <composite:attribute name="value" required="true" /> > </composite:interface> > <composite:implementation> > <h:outputLabel for="input" value="#{cc.attrs.label}" /> > <h:inputText id="input" value="#{cc.attrs.value}" /> > </composite:implementation> > </html> > The calling page: > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> > <html xmlns="http://www.w3.org/1999/xhtml" > xmlns:ui="http://java.sun.com/jsf/facelets" > xmlns:h="http://java.sun.com/jsf/html" > xmlns:f="http://java.sun.com/jsf/core" > xmlns:ez="http://java.sun.com/jsf/composite/demo"> > <h:head></h:head> > <h:body> > <h:form id="form"> > <h:messages /> > <ez:input id="composite" label="Enter something:" > value="#{testBean.value}" /> > <h:commandButton value="Submit" > action="#{testBean.testCcAttribute}" /> > </h:form> > </h:body> > </html> > Here's testBean.testCcAttribute(): > public String testCcAttribute() { > HtmlInputText input = > (HtmlInputText)FacesContext.getCurrentInstance().getViewRoot().findComponent("form:composite:input"); > UIComponent composite = > FacesContext.getCurrentInstance().getViewRoot().findComponent("form:composite"); > String message = "Input control label attribute is: " + > input.getLabel() + "; Composite label attribute is: " + > composite.getAttributes().get("label"); > display(message); > return null; > } > This action method generates the following message: > Input control label attribute is: null; Composite label attribute is: Enter > something: > --- > Full example WAR attached. > Note this is the same as the following issue with Mojarra: > http://java.net/jira/browse/JAVASERVERFACES-2009. -- This message is automatically generated by JIRA. For more information on JIRA, see: http://www.atlassian.com/software/jira