In my JSF 2.0 project, I get a name-space collision when I include two identical XHTML files in a single parent XHTML file. My goal is to create a dashboard of identical controls on a single page, with each control representing a separate context.
For example, in the following JSF file, called parent.xhtml
(say), I include two "dashboard" facelets:
<ui:define name="body">
<p:panel id="ONE" >
<ui:include src="raceboardunit.xhtml"/>
</p:panel>
<p:panel id="TWO" >
<ui:include src="raceboardunit.xhtml"/>
</p:panel>
</ui:define>
To be simple, say the child facelet "raceboardunit.xhtml" is the following:
<ui:composition 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:p="http://primefaces.prime.com.tr/ui">
<p:panel header="Dashboard" >
<h:panelGrid columns="2">
<h:outputLabel value="Event" for="idEvent}" />
<h:outputLabel value="#raceBoardController.name}" id="idEvent" />
</h:panelGrid>
</p:panel>
</ui:composition>
The problem is the collision involving the output label id="idEvent", since in the parent.xhtml
file, the two inclusions of the child facelet have an identical named component.
The error is reported as: Component ID idEvent has already been found in the view.
The reason for the error is obvious, but what is the best way to include a variable number of identical components in a JSF 2.0 application that maximises code reuse?