AAron nAAs created MYFACES-4018:
-----------------------------------
Summary: FacesComponent Property "not found on type
javax.faces.component.UINamingContainer"
Key: MYFACES-4018
URL: https://issues.apache.org/jira/browse/MYFACES-4018
Project: MyFaces Core
Issue Type: Bug
Components: JSR-344
Affects Versions: 2.2.8
Environment: Windows, JSF 2.2, Weld CDI 2.2.16.Final, Eclipse Mars,
OmniFaces 2.1
Reporter: AAron nAAs
When dynamically adding a composite control to a page, any custom
FacesComponent in the composite control can't access its properties.
******* This works *******
Enter value, hit Refresh button.
[ Note: This has the CustComp FacesComponent statically on the page.
Also note:
xmlns:cvc="http://java.sun.com/jsf/composite/com/aadhoc/cvc/spikes/extensionsapproach/components"]
<h:form id="modelerForm">
<h:commandButton value="Refresh" type="submit"/>
<h:outputText value="CustProp:"/>
<cvc:CustComp/>
</h:form>
******* This breaks *******
Hit Add button, then hit Refresh button.
[Note: This dynamically adds a CompTestChild composite, which contains the
CustComp FacesComponent]
<h:form id="modelerForm">
<h:commandButton value="Refresh" type="submit"/>
<h:commandButton value="Add"
actionListener="#{modelerController.compTestOnAdd}"/>
<cvc:CustComp/>
<h1>Controls</h1>
<h:panelGrid id="controlsPanel"/>
</h:form>
Error:
javax.el.PropertyNotFoundException: Property 'prop' not found on type
javax.faces.component.UINamingContainer
viewId=/modeler.xhtml
location=M:\home\eclipse\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\CVC
Spike Extensions Approach\modeler.xhtml
phaseId=PROCESS_VALIDATIONS(3)
Caused by:
javax.el.PropertyNotFoundException - Property 'prop' not found on type
javax.faces.component.UINamingContainer
at javax.el.BeanELResolver$BeanProperties.get(BeanELResolver.java:268)
/resources/com/aadhoc/cvc/spikes/extensionsapproach/components/CustComp.xhtml
at line 20 and column 36 value="#{cc.prop}"
This is my custom FacesComponent (CustComp.xhtml):
<?xml version="1.0" encoding="ISO-8859-1" ?>
<html
xmlns="http://www.w3.org/1999/xhtml"
xmlns:cc="http://java.sun.com/jsf/composite"
xmlns:h="http://java.sun.com/jsf/html"
>
<cc:interface
componentType="com.aadhoc.cvc.spikes.extensionsapproach.CustComp">
</cc:interface>
<cc:implementation>
<h:outputText value="Prop:"/>
<h:inputText value="#{cc.prop}"/>
</cc:implementation>
</html>
Backing:
@FacesComponent(value = "com.aadhoc.cvc.spikes.extensionsapproach.CustComp",
createTag = false)
public class CustComp extends UIInput implements NamingContainer {
private String prop;
public CustComp() {
}
public String getProp() {
return prop;
}
public void setProp(String prop) {
this.prop = prop;
}
@Override
public String getFamily() {
return UINamingContainer.COMPONENT_FAMILY;
}
}
modelerController:
public void compTestOnAdd() {
UIViewRoot viewRoot = FacesContext.getCurrentInstance().getViewRoot();
UIComponent topGroup =
viewRoot.findComponent(":modelerForm:controlsPanel");
FacesContext context = FacesContext.getCurrentInstance();
UIComponent composite = context.getApplication().getViewHandler()
.getViewDeclarationLanguage(context,
context.getViewRoot().getViewId())
.createComponent(context,
"http://xmlns.jcp.org/jsf/composite/com/aadhoc/cvc/spikes/extensionsapproach/components",
"CompTestChild", new HashMap<>());
topGroup.getChildren().add(composite);
}
CompTestChild.xhtml:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:cc="http://java.sun.com/jsf/composite"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:cvc="http://java.sun.com/jsf/composite/com/aadhoc/cvc/spikes/extensionsapproach/components"
>
<cc:interface>
</cc:interface>
<cc:implementation>
<h:panelGrid columns="2">
<h:outputText value="CustProp:"/>
<cvc:CustComp/>
</h:panelGrid>
</cc:implementation>
</html>
web.xml includes:
<resource-env-ref>
<!-- Enable Weld CDI, also needs META-INF/context.xml entry -->
<resource-env-ref-name>BeanManager</resource-env-ref-name>
<resource-env-ref-type>javax.enterprise.inject.spi.BeanManager</resource-env-ref-type>
</resource-env-ref>
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<context-param>
<param-name>org.apache.myfaces.STRICT_JSF_2_ALLOW_SLASH_LIBRARY_NAME</param-name>
<param-value>true</param-value>
</context-param>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)