I have problems including a facelet template. I wanted to split some content up, so that I can reuse it somewhere else.
So I changed this code:
<!DOCTYPE html> <ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets" template="/layout/template.xhtml"> <ui:define name="head"> <title>Title</title> </ui:define> <ui:define name="header"> <h3>Header</h3> </ui:define> <ui:define name="content"> <table><tr><td>table</td></tr></table> </ui:define> </ui:composition> To this:
<!DOCTYPE html> <ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets" template="/layout/template.xhtml"> <ui:define name="head"> <title>Title</title> </ui:define> <ui:include src="/admin/admin_generic.xhtml"/> </ui:composition> And inside admin-generic.xhtml I wrapped the code in a ui:composition.
<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets"> <ui:define name="header"> <h3>Header</h3> </ui:define> <ui:define name="content"> <table><tr><td>table</td></tr></table> </ui:define> </ui:composition> But nothing is shown. I just get a blank page, with no errors. Is it wrong using ui:composition? I have tried with ui:component but that didn't help either.
Update: According to my Facelets Essentials Guide, it says:
The
ui:includetag can be used to include another Facelets file into your document. It simply includes whatever source file you specify. You can include any Facelets file that hasui:componentorui:compositiontags (which trim the content outside themselves) or simply a fragment of XHTML or XML.
Is that what is going on? Is the content outside of the include trimmed away? How can I just include the page, without the content outside being trimmed?