I am trying to implement a dynamic rendering on a JSF composite component (I'm using Primefaces). Basically, I figured that many rendering component are like "header + content" based. I would like to make a generic implementation in which the developer doesn't have to care about how the rendering is done (and the rendering could be configurable via another bean in the app. That is, something like :
The main component (accordion / tabview / grid, etc)
<composite:implementation>
<p:accordionPanel rendered="#{composite.attrs.renderingType eq 'accord'}>
<composite:insertChildren/>
</p:accordionPanel>
<p:tabView rendered="#{composite.attrs.renderingType eq 'accord'}>
<composite:insertChildren>
<f:param name="renderingType" value="accord"/>
</composite:insertChildren>
</p:tabView>
<c:if test="#{composite.attrs.renderingType eq null}">
<composite:insertChildren>
<f:param name="renderingType" value="tabView"/>
</composite:insertChildren>
</c:if>
</composite:implementation>
The "item" component (a accordion tab, a tabview tab, a simple grid, etc)
<composite:implementation>
<p:tab rendered="${renderingType eq 'accord'}">
<composite:insertChildren/>
</p:accordionPanel>
<p:tabView rendered="${renderingType eq 'tabView'}">
<composite:insertChildren/>
</p:tabView>
//....etc.
</composite:implementation>
The call for those composite components would be :
<appcc:myCustomRenderer renderingType='How I want to render it'>
<appcc:myCustomRendererItem header="Title1">
//Content 1
</appcc:myCustomRendererItem>
<appcc:myCustomRendererItem header="Title2">
//Content 2
</appcc:myCustomRendererItem>
//Etc.
</appcc:myCustomRenderer>
At the moment I didn't think about facets (should I ?) for this implementation. in a simple case (the main component renders only an accordion panel, and the item component renders only one tab), it doesn't seem to work. ANy idea why ?
//Main component
<composite:implementation>
<p:accordionPanel>
<composite:insertChildren/>
</p:accordionPanel>
</composite:implementation>
//Item Component
<composite:implementation>
<p:tab >
Any content
</p:tab>
</composite:implementation>
Thank you!