• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem rendering facelets templates

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello All,

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:

MyTempalte.xhtml:


footer.xhtml:


BasicPage.jsp:


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?



 
Ranch Hand
Posts: 199
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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


Hope this helps.
 
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Jakim Rachev
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks everyone!

@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.

Thank you guys
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic