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 3346316
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T01:17:21+00:00 2026-05-18T01:17:21+00:00

I have problems including a facelet template. I wanted to split some content up,

  • 0

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:include tag 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 has ui:component or ui:composition tags
(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?

  • 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-05-18T01:17:21+00:00Added an answer on May 18, 2026 at 1:17 am

    The <ui:define> has to be placed in an <ui:composition> or <ui:decorate> with a template containing the appropriate <ui:insert> tags. You’ve moved it to an <ui:composition> without a template. No template means no content.

    Technically, to achieve your requirement, you have to replace the <ui:include> by <ui:insert>.

    <!DOCTYPE html>
    <ui:composition
        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="template.xhtml">
    
        <ui:define name="head">
            <title>Title</title>
        </ui:define>
    
        <ui:insert />
    </ui:composition>
    

    And declare the above page (I assume it as somepage.xhtml) as template in admin_generic.xhtml.

    <!DOCTYPE html>
    <ui:composition
        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="somepage.xhtml">
    
        <ui:define name="header">
            <h1>Header</h1>
        </ui:define>
    
        <ui:define name="content">
            <table><tr><td>table</td></tr></table>
        </ui:define>
    </ui:composition>
    

    Note that you have to open admin_generic.xhtml in the browser instead. If your intent is to open somepage.xhtml in browser, then the <ui:define> really has to stay in somepage.xhtml. You can however replace the body of <ui:define> by a simple <ui:include>.

    <!DOCTYPE html>
    <ui:composition 
        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="template.xhtml">
    
        <ui:define name="head">
            <title>Title</title>
        </ui:define>
    
        <ui:define name="header">
            <h1>Header</h1>
        </ui:define>
    
        <ui:define name="content">
            <ui:include src="admin_generic.xhtml" />
        </ui:define>
    </ui:composition>
    

    It allows for <ui:composition>, so you don’t necessarily need to put the <table> to root.

    <!DOCTYPE html>
    <ui:composition 
        xmlns:f="http://java.sun.com/jsf/core"
        xmlns:h="http://java.sun.com/jsf/html"
        xmlns:ui="http://java.sun.com/jsf/facelets">
    
        <table><tr><td>table</td></tr></table>
    </ui:composition>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have problems getting some of my views aligned in a relative layout that
I have problems with dealing with widows within a multicols environment, that is, I
What's new in jQuery(including UI) and will I have problems(using UI dialog and datepicker)
i have some Problems with my iPad Code. I have a UITabBarController which holds
We have an ASP.NET application that queues some of its long-running operations (generating reports,
I am after some input/guidance.. I have an application that uses a central configuration
I'm writting a WPF program.And now i have some problems. There is a Window
I have an Excel VBA function that takes a number of optional parameters, including
I have a bizarre problem that is causing us problems. We have a simple
We have one large xslt that renders a whole shop area including products, manifacturers

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.