Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8207069
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T08:53:10+00:00 2026-06-07T08:53:10+00:00

I can’t get facelets file to load into a template. I have a content

  • 0

I can’t get facelets file to load into a template.

I have a content facelet called frontpage.xhtml that is set as the welcome page in web.xml. This loads the template. The template then is to include a number of other files. When they wouldn’t load I pared it down to one (header.xhtml) to try to troubleshoot. It wouldn’t even load when I put the header xhtml file in the same directory as the template and frontpage file.

When the app is run the frontpage.xhtml is run inside the template. I can see this because I can see the effects of the css loaded in the template. And I can see the “Hello World” in the title bar and “Hello World!” displayed in the page. But the header is not loaded at the top.

I tried removing all div and class info from the template body as well. There are none in the facelets. It didn’t help.

Can someone provide some insight here? Maybe I’m off base, but I thought I could define the template this way so that I could call different facelets that load into the template’s content area.

This app does run correctly without the templating. i.e. when everything is lumped into one page, which I am trying get away from for modularity.

Directory Structure (starting at the root for web pages)

/frontpage.xhtml
/soulard_base_template.xhtml
/sections/base/header.xhtml

web.xml (what I think are the relevant sections)

<context-param>
    <param-name>javax.faces.PROJECT_STAGE</param-name>
    <param-value>Development</param-value>
</context-param>
<servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<welcome-file-list>
    <!--<welcome-file>faces/welcome.xhtml</welcome-file>-->
    <welcome-file>faces/frontpage.xhtml</welcome-file>
</welcome-file-list>

frontpage.xhtml

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets">
  <body>
    <ui:composition template="soulard_base_template.xhtml">
      <ui:define name="windowTitle">
        Hello World
      </ui:define>
      <ui:define name="content">
        <h2>Hello World!</h2> 
      </ui:define>
    </ui:composition>
  </body>
</html>

soulard_base_template.xhtml

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui">

  <h:head>
    <title><ui:insert name="windowTitle" /></title>
    <link href="${facesContext.externalContext.requestContextPath}/css/print.css" rel="stylesheet" type="text/css" media="print" />
    <link href="${facesContext.externalContext.requestContextPath}/css/screen.css" rel="stylesheet" type="text/css" media="screen, projection" />
    <!--[if lt IE 8]>
    <link href="${facesContext.externalContext.requestContextPath}/css/ie.css" rel="stylesheet" type="text/css" media="screen, projection" />
    <![endif]-->
    <link href="${facesContext.externalContext.requestContextPath}/css/soulardtheme.css" rel="stylesheet" type="text/css" media="screen, projection" />
    <link href="${facesContext.externalContext.requestContextPath}/css/soulard_base.css" rel="stylesheet" type="text/css" media="screen, projection" />

  </h:head>
  <h:body>
    <div class="container showgrid" title="Container">
      <div class="span-24" title="Banner">
        <ui:insert name="header">
          <ui:include src="sections/base/header.xhtml"/>
        </ui:insert>
      </div><!-- End of Banner -->

      <div class="span-16" title="Content Column">
        <ui:insert name="content" />
      </div><!-- End of Centre Column -->
    </div><!-- End of Container -->
  </h:body>

</html>

header.xhtml

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html">
  <body>
    <ui:composition>
      <ui:define name="header">
        <h2>Header</h2>
        <h:graphicImage url="/images/header.png" 
                        width="950"
                        height="175"/>
      </ui:define>
    </ui:composition>
  </body>
</html>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T08:53:12+00:00Added an answer on June 7, 2026 at 8:53 am

    The problem is the additional “define” entry in header.xhtml <ui:define name="header">. You use ui:define usually to replace some content from a template, but note the outer <ui:composition> does not have a reference to a template. So, if there is no template, facelets doesn’t know where to apply it, and finally the inner content is never used.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can I load admob ad using AsyncTask ? I have tried it but I
I have a jquery bug and I've been looking for hours now, I can't
I have just tried to save a simple *.rtf file with some websites and
can someone explain why the compiler accepts only this code template<typename L, size_t offset,
Can't figure out how to do this in a pretty way : I have
Can we change the color of the divider? Apple documentations says, that we can
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Can anyone help me with an excel formula that groups related rows and creates
Can you have submenus with the top level set to checkable in WPF? I
Can't seem to get the Back Button to appear in a UINavigationController flow. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.