JSF Primeface Composite Component Example (To reuse component)
Create composite component example: checkbox.
setup facelet-taglib in META-INF Folder:Â
<facelet-taglib version="2.2"   xmlns="http://xmlns.jcp.org/xml/ns/javaee"   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"   xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-facelettaglibrary_2_2.xsd">  <namespace>http://www.somelink.com/somelink/composite</namespace>  <tag>   <tag-name>compositeBox</tag-name>   <component>    <resource-id>     component-path/compositeBox.xhtml    </resource-id>   </component>  </tag> </facelet-taglib>
create composite (compositeBox.xhtml):
<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:composite="http://java.sun.com/jsf/composite"> Â Â <composite:interface> <composite:attribute name="SelectCheckbox" /> Â Â <composite:attribute name="valueItem" /> Â Â <composite:attribute name="value" /> Â Â <composite:attribute name="bean" /> Â Â Â <composite:attribute name="update" /> Â Â Â <composite:attribute name="disable" /> Â Â </composite:interface> Â Â <composite:implementation> Â Â <p:selectManyCheckbox id="idCheckbox" value="#{cc.attrs.value}"Â disabled="#{cc.attrs.disable}"> <p:ajax event="change" update="#{cc.attrs.update}" listener="#{cc.attrs.bean.selectAll}"/> <f:selectItem itemLabel="ALL" itemValue="all" /> Â Â <f:selectItems value="#{cc.attrs.valueItem}" var="select" itemLabel="#{select.code.concat(' - ').concat(select.name)}" itemValue="#{select.code}" /> </p:selectManyCheckbox> Â Â Â </composite:implementation> </ui:composition>
To use created composite component:
declare in ui:composition
<ui:composition xmlns="http://www.w3.org/1999/xhtml" Â xmlns:usehere="http://www.somelink.com/somelink/composite">
to use component:
<usehere:compositeBox id="idCheckBoxList" update=":from" valueItem="#{bean.item}" bean="#{bean}" value="#{bean.CheckBoxList}" disable="#{bean.isEdit}"/>














