I have this problem: I want to create a composition template and to inclide a page content into a target page.
Here is the code of my template, page cantent that i want to be included and the target page:
As you can see the sample project is very simple.
However when I open BasicPage.jsf in a browser, I see the content enclosed in <h1> tags, which deviates from the expectations.
The content of footer.xhtml is not included and the header part is not displayed. Only the body part is renderd.
Can you please help me out?
First I was going to address you on the typo MyTempalte.xhtml but I see that you have used it both in your code and in your filename so that should not be an issue
Are you using JSF 1 or JSF 2? I am only familiar how the templates should be applied on JSF 2 and there I would recommend that you do not try to use jsp but only use xhtml pages. And if you only use xhtml then the page should be BasicPage.xhtml and start with
First off, make sure you're not making the mistake that everyone makes. That mistake is confusing the resource name with the URL name.
The URL is what the client uses to reference things. The resource name is the actual name of the resource file in the WAR. The distinction is critical in JSF, since if you supply a url such as "host:/context/myPage.jsf" and you have your web.xml URL handlers set up the same way that I (and a lot of other people) do, the container will pick up on the "*.jsf" URL pattern, route the URL to the FacesServlet, and the FacesServlet will dissect the URL and convert it to the resource name "myPage.xhtml".
If you use the ".jsp" extension and your mappings are not set up properly, the Facelets code won't translate properly and the Facelets templating process will not be applied. Since Facelets was originally a separate subsystem prior to JSF2, Facelets has its own configuration options that work in conjunction with the FacesServlet processing.
Bjoke: A "Bully Joke". A Statement or action made with malicious intent - unless challenged. At which point it magically transforms into "I was just funnin'" or "What's the matter, can't take a joke?"
@Ilari Moilanen the prolem was that I reference the tamplate with the "src" property instead of the "template" property of the <ui:compositin>.
After I tryed out your proposition i found that mistake in my sample code. Now everything is fine and it is working as expected.
@Tim Holloway thank you for this information. I think it will come usefull to me.