I'm creating a composite component in my application with following code :
<?xml version="1.0" encoding="UTF-8"?>
<!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:p="http://primefaces.org/ui"
xmlns:composite="http://xmlns.jcp.org/jsf/composite">
<composite:interface>
<composite:attribute name="url" required="true" type="java.lang.String" />
<composite:attribute name="label" required="true" type="java.lang.String" />
<composite:attribute name="compId" required="true" type="java.lang.String" />
</composite:interface>
<composite:implementation>
<p:menuitem id="#{cc.attrs.compId}" value="#{cc.attrs.label}" url="#{cc.attrs.url}" />
</composite:implementation>
</html>
And am using this composite component in my index page as following:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:p="http://primefaces.org/ui"
xmlns:ex="http://xmlns.jcp.org/jsf/composite/example">
<h:head>
<f:facet name="first">
<meta content='text/html; charset=UTF-8' http-equiv="Content-Type"/>
<title>PrimeFaces</title>
</f:facet>
</h:head>
<h:body>
<p:menu>
<p:submenu id="admin" label="Admin" >
<ex:menuItem label="Go" url="www.google.com" compId="tempMenu"/>
</p:submenu>
</p:menu>
</h:body>
</html>
But whenever I'm trying to access index.xhtml page am getting following error.
javax.faces.component.UINamingContainer cannot be cast to org.primefaces.model.menu.MenuElement
But if i create composite component with following changes in composite:implementation part it's working fine.
composite component :
<p:menu>
<p:submenu id="admin" label="Admin" >
<p:menuitem value="#{cc.attrs.label}" url="#{cc.attrs.url}" id="#{cc.attrs.compId}"/>
</p:submenu>
</p:menu>
index.xhtml:
<ex:menuItem label="Go" url="www.google.com" compId="tempMenu" />
Why am I getting javax.faces.component.UINamingContainer cannot be cast to org.primefaces.model.menu.MenuElement
while creating composite component? Any help would really useful. Thanks in advance.