brbrbr
brbrbr

Reputation: 157

ui:insert not being replaced by ui:define

I'm creating a JSF template to follow a layout on my application... so I created this layout.xhtml page.

<?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:f="http://java.sun.com/jsf/core"
    xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
    xmlns:h="http://xmlns.jcp.org/jsf/html">

<h:head>
    <link href="stylesheet.css" rel="stylesheet" type="text/css" />
</h:head>
<h:body>
    <f:loadBundle basename="mensagens.mensagens_pt_BR" var="msgs" />
    <ui:composition>
        <div id="page">
            <div id="header-container">
                <div id="nomeSistema">#{msgs.outNomeSistema}</div>
            </div>
            <div id="menu-login-container">
                <div id="menu"
                    style="width: 850px; height: 30px; border: solid 1px; padding: 15px;">
                    <ui:include src="/menu/menu.xhtml" />
                </div>
                <div id="login">
                    <ui:include src="/login/login.xhtml" />
                </div>
            </div>
            <div id="content-container">
                <div id="content">
                    <ui:insert name="content">
                        <h2>Default content</h2>
                    </ui:insert>
                </div>
            </div>
            <div id="footer-container">
                <div id="footer">
                    <h:outputText value="#{msg.versao}" />
                </div>
            </div>
        </div>
    </ui:composition>
</h:body>
</html>

And here is the comum.xhtml

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:ui="http://java.sun.com/jsf/facelets" template="layout.xhtml">
    <ui:define name="content">
        <h2>Testando template...</h2>
    </ui:define>
</ui:composition>

but, when I access the comum.xhtml page on my browser. The text Default content is show, not Testando template....

What I'm doing wrong?

Upvotes: 2

Views: 973

Answers (1)

brbrbr
brbrbr

Reputation: 157

I found it!

on html tag of layout.xhtml I changed it from

<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
    xmlns:h="http://xmlns.jcp.org/jsf/html">

to

<html 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">

and now, it's working.

Upvotes: 2

Related Questions