Pessoal,
Estou desenvolvendo o template, a minha estrutura esta no anexo
segue abaixo o meu codigo :
index.xhtml
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
template="./../template/Template.xhtml">
<ui:define name="top">
top
</ui:define>
<ui:define name="left">
left
</ui:define>
<ui:define name="content">
content
</ui:define>
<ui:define name="bottom">
bottom
</ui:define>
</ui:composition>
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:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html">
<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link href="./../resources/css/default.css" rel="stylesheet" type="text/css" />
<link href="./../resources/css/cssLayout.css" rel="stylesheet" type="text/css" />
<title>Facelets Template</title>
</h:head>
<h:body>
<div id="top">
<ui:insert name="top">Top</ui:insert>
</div>
<div>
<div id="left">
<ui:insert name="left">Left</ui:insert>
</div>
<div id="content" class="left_content">
<ui:insert name="content">Content</ui:insert>
</div>
</div>
<div id="bottom">
<ui:insert name="bottom">Bottom</ui:insert>
</div>
</h:body>
</html>
quando acesso o template.xhtml aparece normalmente o layout, mas quando acesso o index.xhtml nao aparece o
layout, da a impressão que nao esta achando o template.
Alguem pode me ajudar ?

isso naum funciona desse jeito
template="…/template/Template.xhtml"
tentei fazer dessa forma
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
template="../templates/templates.xhtml">
mas a pagina fica em branco agora
Boa Tarde,
Eu faço da seguinte forma:
Declaro a taglib: xmlns:ui=“http://java.sun.com/jsf/facelets”
// Declaração do template
<ui:composition template="/templates/template.xhtml">
<ui:define name="conteudo">
//Aqui vai o conteúdo da página
</ui:define>
</ui:composition>
meu index, esta na pasta PAGE, e tentei fazer dessa forma :
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
template="/templates/templates.xhtml">
<ui:define name="header">
header index
</ui:define>
e minha pasta TEMPLATES/templates.xhtml
nao esta achando o meu template
Tentei fazer dessa forma, mas mesmo assim nao rolou
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
template="/templatenovo1/web/templates/templates.xhtml">
<ui:define name="header">
header index
</ui:define>
Note o erro de caminho voce colocou
[quote]<ui:composition xmlns:ui=“http://java.sun.com/jsf/facelets”
template="…/templates/templates.xhtml"> [/quote]
enquanta na imagem que voce postou a pasta do template tem o nome de template
entao o certo não seria :
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
template="../template/Template.xhtml">
tentei da forma , mas nao rolou .
anexei o projetinho …é bem pequeno , se algum poder dar uma olhada .
Tenta colocar o diretório dessa forma:
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
template="${facesContext.externalContext.request.contextPath}/template/Template.xhtml">
Evandro, blza!
criei um projeto teste e não tive o problema que está relatando. Vou postar os códigos, veja se pode te ajudar vlw!
Abraços…
P.S. utilizei e mesma estrutura de diretórios mencionado, limpei e construí o projeto usando NetBeans + Glassfish e apenas executei o arquivo index.xhtml (Shift + F6)
template.xhtml
[code]<?xml version='1.0' encoding='UTF-8' ?>
<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link href="./../resources/css/default.css" rel="stylesheet" type="text/css" />
<link href="./../resources/css/cssLayout.css" rel="stylesheet" type="text/css" />
<title>Facelets Template</title>
</h:head>
<h:body>
<div id="top">
<ui:insert name="top">Top</ui:insert>
</div>
<div>
<div id="left">
<ui:insert name="left">Left</ui:insert>
</div>
<div id="content" class="left_content">
<ui:insert name="content">Content</ui:insert>
</div>
</div>
<div id="bottom">
<ui:insert name="bottom">Bottom</ui:insert>
</div>
</h:body>
[/code]
index.xhtml
[code]<?xml version='1.0' encoding='UTF-8' ?>
top
<ui:define name="left">
left
</ui:define>
<ui:define name="content">
content
</ui:define>
<ui:define name="bottom">
bottom
</ui:define>
</ui:composition>
[/code]
e web.xml
[quote]<?xml version="1.0" encoding="UTF-8"?>
javax.faces.PROJECT_STAGE
Development
Faces Servlet
javax.faces.webapp.FacesServlet
1
Faces Servlet
/faces/*
30
faces/index.xhtml
[/quote]