I have created facelet template:
left-right.xhtml
<ui:composition>
<ui:include name="left" />
<hr />
<ui:include name="right" />
</ui:composition>
After, if I use this template with ui:decorate it works fine:
index.xhtml
<ui:decorate template="left-right.xhtml">
<ui:define name="left">FOO</ui:define>
<ui:define name="right">BAR</ui:define>
</ui:decorate>
BUT, if I use this template as custom facelet tag it does not works.
custom-taglib.xml
<facelet-taglib>
<tag>
<tag-name>leftright</tag-name>
<source>left-right.xhtml</source>
</tag>
</facelet-taglib>
index.xhtml
<custom:leftright>
<ui:define name="left">FOO</ui:define>
<ui:define name="right">BAR</ui:define>
</custom:leftright>
The content inside ui:define tags is not included into template 🙁
So, question is how can I parameterise facelet template if it renders as facelet custom tag?
(note that you have a syntax error in your
left-right.xhtml, you should be using<ui:insert>instead of<ui:include>, but I’ll assume it to be just careless oversimplification)A tag file cannot be treated as a template client. You need to approach it differently depending on the concrete functional requirement. If you’re on JSF 2.x, then a composite component would be the closest which you need. You could define the parts as
<f:facet>and render them by<cc:renderFacet>in the composite implementation.E.g.
/resources/custom/leftRight.xhtmlUsage:
But if you’re still on JSF 1.x, you cannot create a composite component. You’d need to stick to
<ui:decorate>.See also: