Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Not A Problem
-
2.0.7
-
None
-
None
-
Mac OS 10.6, Tomcat 7
Description
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="#
" />
<h:inputText id="input" 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="#
" />
<h:commandButton value="Submit" action="#
" />
</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.