0

I have created a basic JSF template called Template.xhtml. This template is then being used by the page TestPage.xhtml. In my TestPage.xhtml i have only used the <ui:define> tag to override the pages title. Therefore, I would have expected the rest of the templates content to be displayed the same. However, only the header and footer of the template are being displayed.

Template.xhtml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html> 

<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:ace="http://www.icefaces.org/icefaces/components"
    xmlns:icecore="http://www.icefaces.org/icefaces/core"
    xmlns:ice="http://www.icesoft.com/icefaces/component"
    >

<h:head>
<title><ui:insert name="title"></ui:insert></title>
<link href="#{request.contextPath}/resources/css/Template.css" rel="stylesheet"/>

</h:head>

<h:body>

<header id ="header">
<ui:insert name="header">
<h1>OAG Reference Data</h1>
</ui:insert>
</header>



<section id="container">
<ui:insert>

<section id="sidebar">
<ui:insert name="sideBar">
<h:form>
<ace:menu type="sliding" zindex="2">
    <ace:submenu label="Carrier">
        <ace:menuItem value="General Carrier Data" />
        <ace:menuItem value="Contact Info" />
        <ace:menuItem value="Alliance Membership" />
    </ace:submenu>
</ace:menu>
</h:form>
</ui:insert>
</section>

<section id="content">
<ui:insert name="content">
<h1>Content</h1>

</ui:insert>
</section>

</ui:insert>
</section>


<footer id ="footer">
<ui:insert name="footer">
<h1>Footer#{bundle['application.defaultpage.footer.content']}</h1>
</ui:insert>
</footer>



</h:body>
</html>

Template.xhtml screenshot

TestPage.xhtml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:icecore="http://www.icefaces.org/icefaces/core"
    xmlns:ace="http://www.icefaces.org/icefaces/components"
    xmlns:ice="http://www.icesoft.com/icefaces/component">

<ui:composition template="WEB-INF/templates/Template.xhtml">

<ui:define name="title">
Test Title
</ui:define>

<ui:define name="content">
Test Content
</ui:define>


</ui:composition>

</html>

TestPage.xhtml screenshot

Does anybody know why the footer and header sections are being displayed as part of the template, but why the other content and sidebar sections are not (despite me not overriding them).

Thanks.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
LiamWilson94
  • 458
  • 2
  • 7
  • 26

1 Answers1

1

You need to put <ui:insert name="Container"> instead of <ui:insert> in the "container" section.

The content is not shown because the ui insert tag has no name so you can't refer to it.

Tiny
  • 27,221
  • 105
  • 339
  • 599