Search code examples
templatesjsfjsf-2facelets

Change dynamic part of an snippet that is included via JSF-2.0 templateing


I have a problem with the JSF-2.0 templating mechanism. I implement some snippet that are included to template file. But one of my snippet contains dynamic content.

I do not get an error. But nothing is replaced in my snipplet! The result do only contain "No link list could be found" string. Do anybody know why?

Thanks

The snippet code

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
  xmlns:ui="http://java.sun.com/jsf/facelets">
    <div>
    <ui:insert name="linkList">No link list could be found</ui:insert> 
    </div>
    © MyCompany
</ui:composition>

The template code

  ...
  <div class="footer">
    <ui:insert name="footer">Footer</ui:insert>
  </div>
  ...

The side where specify the template content

...
<ui:define name="footer">
  <ui:include src="/snippets/footer.xhtml" />
</ui:define>
...
<ui:define name="linkList">
link structure for the footer
</ui:define>

Solution

  • The following line you have in snippet is -

    <ui:insert name="linkList">No link list could be found</ui:insert>
    

    is for templating and it should be in the template.

    Include the snippet in the same way you have included the footer. Using

    <ui:include src="snippet.xhtml" />