I made a composite component for upload files that have a datatable (to show uploaded files) like this:
<!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:c="http://java.sun.com/jsp/jstl/core"
xmlns:fn="http://java.sun.com/jsp/jstl/functions"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:composite="http://java.sun.com/jsf/composite"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
<head>
<title>File Upload Component</title>
</head>
<body>
<composite:interface componentType="components.Customfileupload">
<composite:attribute name="list" required="true"
type="java.util.List" />
<<more attributes>>
</composite:interface>
<composite:implementation>
<div id="#{cc.clientId}">
<f:event type="preRenderComponent" listener="#{cc.init()}"/>
<p:dataTable id="fileUploadTable" value="#{cc.list}" var="n">
<<datatable content>>
</p:datatable>
<p:fileUpload fileUploadListener="#{cc.handleFileUpload}"
mode="advanced" dragDropSupport="false" />
</div>
</composite:implementation>
</body>
</html>
and the backing component
@FacesComponent(value="components.Customfileupload")
public class CustomFileUpload extends UIInput implements NamingContainer, Serializable {
private List<FileUploadItem> list;
@Override
public void restoreState(FacesContext context, Object state) {
Object values[] = (Object[]) state;
super.restoreState(context, values[0]);
list = (List<FileUploadItem>) values[1];
}
@Override
public Object saveState(FacesContext context) {
Object[] values = new Object[2];
values[0] = super.saveState(context);
values[1] = list;
return values;
}
public void init() {
ValueExpression expr = super.getValueExpression("list");
ELContext ctx = super.getFacesContext().getELContext();
this.list = (List<FileUploadItem>) expr.getValue(ctx);
}
public List<FileUploadItem> getList() {
return list;
}
<<more code>>
Using
<mpc:fileupload list="#{myBean.fileUploadList}" />
When use alone works ok, but when use with another composite component in same page throws exception:
Exception type: class javax.el.PropertyNotFoundException
Exception message: .../fileupload.xhtml @59,100 value="#{cc.list}": The class 'javax.faces.component.UINamingContainer' does not have the property 'list'.
I've more composite components that works fine together. The exception occurs only for fileupload. This problem seems to be similar with this topic, but in my case the composite components doesn't nested.
Edit: The composite component used together with mpc:fileupload is mpc:balloon that uses basically primefaces overlayPanel, like:
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:fn="http://java.sun.com/jsp/jstl/functions"
xmlns:composite="http://java.sun.com/jsf/composite"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
<head>
<title>Baloon Component</title>
</head>
<body>
<composite:interface>
<composite:attribute name="for" />
<composite:attribute name="dynamic" default="true" />
</composite:interface>
<composite:implementation>
<p:overlayPanel for="@parent:@parent:@parent:#{cc.attrs.for}"
dynamic="cc.attrs.dynamic"
widgetVar="#{fn:replace(cc.clientId, ':', '_')}_widgetVar"
showEvent="mouseover" hideEvent="mouseout"
dismissable="false" appendToBody="true"
onShow="onShowOverlayPanel(this)">
<composite:insertChildren />
</p:overlayPanel>
</composite:implementation>
</body>
</html>
Stack trace
javax.el.PropertyNotFoundException: ../fileupload.xhtml @58,100 value="#{cc.list}": The class 'javax.faces.component.UINamingContainer' does not have the property 'list'.
at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:111)
at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:194)
at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:182)
at javax.faces.component.UIData.getValue(UIData.java:730)
at org.primefaces.component.api.UIData.getDataModel(UIData.java:764)
at org.primefaces.component.api.UIData.setRowModel(UIData.java:571)
at org.primefaces.component.api.UIData.setRowIndexWithoutRowStatePreserved(UIData.java:564)
at org.primefaces.component.api.UIData.setRowIndex(UIData.java:473)
at javax.faces.component.UIData.invokeOnComponent(UIData.java:1039)
at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:1466)
at javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:671)
at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:1466)
at javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:671)
at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:1466)
at javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:671)
at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:1466)
at javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:671)
at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:1466)
at javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:671)
at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:1466)
at javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:671)
at org.primefaces.component.api.UITabPanel.invokeOnComponent(UITabPanel.java:798)
at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:1466)
at javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:671)
at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:1466)
at javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:671)
at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:1466)
at javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:671)
at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:1466)
at javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:671)
at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:1466)
at javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:671)
at org.primefaces.util.ComponentTraversalUtils.firstById(ComponentTraversalUtils.java:151)
at org.primefaces.expression.SearchExpressionFacade.resolveComponentById(SearchExpressionFacade.java:521)
at org.primefaces.expression.SearchExpressionFacade.resolveClientIds(SearchExpressionFacade.java:246)
at org.primefaces.util.AjaxRequestBuilder.addExpressions(AjaxRequestBuilder.java:93)
at org.primefaces.util.AjaxRequestBuilder.update(AjaxRequestBuilder.java:86)
at org.primefaces.renderkit.CoreRenderer.buildAjaxRequest(CoreRenderer.java:389)
at org.primefaces.component.commandbutton.CommandButtonRenderer.buildRequest(CommandButtonRenderer.java:130)
at org.primefaces.component.commandbutton.CommandButtonRenderer.encodeMarkup(CommandButtonRenderer.java:69)
at org.primefaces.component.commandbutton.CommandButtonRenderer.encodeEnd(CommandButtonRenderer.java:54)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:877)
at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:312)
at com.sun.faces.renderkit.html_basic.GroupRenderer.encodeChildren(GroupRenderer.java:105)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:847)
at org.primefaces.renderkit.CoreRenderer.renderChild(CoreRenderer.java:85)
at org.primefaces.renderkit.CoreRenderer.renderChildren(CoreRenderer.java:72)
at org.primefaces.component.overlaypanel.OverlayPanelRenderer.encodeMarkup(OverlayPanelRenderer.java:59)
at org.primefaces.component.overlaypanel.OverlayPanelRenderer.encodeEnd(OverlayPanelRenderer.java:37)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:877)
at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:312)
at com.sun.faces.renderkit.html_basic.GroupRenderer.encodeChildren(GroupRenderer.java:105)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:847)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1819)
at com.sun.faces.renderkit.html_basic.CompositeRenderer.encodeChildren(CompositeRenderer.java:78)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:847)
at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:304)
at com.sun.faces.renderkit.html_basic.GroupRenderer.encodeChildren(GroupRenderer.java:105)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:847)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1819)
at com.sun.faces.context.PartialViewContextImpl$PhaseAwareVisitCallback.visit(PartialViewContextImpl.java:543)
at com.sun.faces.component.visit.PartialVisitContext.invokeVisitCallback(PartialVisitContext.java:183)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1652)
at org.primefaces.component.api.UIData.visitColumnContent(UIData.java:1014)
at org.primefaces.component.api.UIData.visitRows(UIData.java:988)
at org.primefaces.component.api.UIData.visitTree(UIData.java:842)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1663)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1663)
at org.primefaces.component.api.UITabPanel.visitTree(UITabPanel.java:920)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1663)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1663)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1663)
at javax.faces.component.UIForm.visitTree(UIForm.java:362)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1663)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1663)
at com.sun.faces.context.PartialViewContextImpl.processComponents(PartialViewContextImpl.java:383)
at com.sun.faces.context.PartialViewContextImpl.processPartial(PartialViewContextImpl.java:302)
at javax.faces.context.PartialViewContextWrapper.processPartial(PartialViewContextWrapper.java:183)
at org.primefaces.context.PrimePartialViewContext.processPartial(PrimePartialViewContext.java:57)
at javax.faces.component.UIViewRoot.encodeChildren(UIViewRoot.java:973)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1819)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:421)
at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:125)
at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:286)
at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:286)
at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:286)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:120)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:295)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:100)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:246)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
at org.omnifaces.filter.FacesExceptionFilter.doFilter(FacesExceptionFilter.java:56)
at org.omnifaces.filter.HttpFilter.doFilter(HttpFilter.java:77)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:246)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:231)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:149)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:512)
at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:169)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:150)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:97)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:102)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:344)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:854)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:653)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:926)
at java.lang.Thread.run(Thread.java:745)