Ui:define nao funciona

6 respostas
E

Pessoal estou usando um template mas quando eu defino minha pagina com o ui:define e tento entrar na pagina nao aparece =[

Veja o template
<?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:rich="http://richfaces.org/rich"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets">

<h:head>
	<h:outputStylesheet name="agenciaturismo.css" />
</h:head>

<h:body>
	<div class="linhaTopo"></div>
	<div class="tudo">
		<div class="topo">
			<div class="clear"></div>
		</div>
		<div class="conteudo">
			<ui:insert name="menu">
				<ui:include src="/publico/menu.xhtml" />
			</ui:insert>
			<h:panelGroup styleClass="msgs_panelGroup" id="errors">
				<rich:messages layout="table" fatalClass="erro" infoClass="info"
					showDetail="true" warnClass="alerta" errorClass="erro">
				</rich:messages>
			</h:panelGroup>			
				<ui:insert name="corpo">// AQUI ESTA O INSERT
				</ui:insert>			
			<div class="clear"></div>
		</div>
		<div class="rodape"></div>
	</div>
</h:body>
</html>
Aqui e a pagina
<?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"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:f="http://java.sun.com/jsf/core">


<ui:composition template="/publico/template.xhtml" />
<h:form>
	<ui:define name="corpo">
		<h:outputLabel value="NAO FUNCIONA" />
	</ui:define>
</h:form>
</html>

Mas nao aparece o label =[

6 Respostas

D
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui"
	xmlns:f="http://java.sun.com/jsf/core"
	template="templates/template.xhtml">
	<ui:define name="metadata">
	</ui:define>
	<ui:define name="content">
	
	HELLO
	
    		

	</ui:define>
</ui:composition>

veja se o código acima te ajuda :)
ps: estou usando o primefaces, então disconsidere o "p" declarado la no xml

E

Po velho ai c teve o Dom :smiley:

Isso ai mudou com o JSF 2?

D

Não sei cara…
Eu sou novato com JSF
kkkkkk

desculpa :frowning:

E

kkk pois e velho, eu fazia do jeito que eu postei com JSF 1.2, ai comecei um projeto com o 2.0 e deu pau kkk, com esse codigo que vc me passou deu certo :smiley:

R

Antes de mais nada, desculpe reviver o post. Mas estou tendo o mesmo problema com o meu layout…

Segue o código do meu layout

layout.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://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>
	<div id="page">
		<div id="header-container">
			<div id="nomeSistema">
				<ui:insert name="nomeSistema">
					<h2>Default nomeSistema</h2>
				</ui:insert>
			</div>
		</div>
		<div id="menu-login-container">
			<div id="menu">
				<ui:insert name="menu">
					<h2>Default menu</h2>
				</ui:insert>
			</div>
			<div id="login">
				<ui:insert name="login">
					<h2>Default login</h2>
				</ui:insert>
			</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">
				<ui:insert name="footer">
					<h2>Default footer</h2>
				</ui:insert>
			</div>
		</div>
	</div>
</h:body>
</html>

E aqui a página que criei para testar…

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

<h:head></h:head>
<h:body>
	<ui:composition template="layout.xhtml">
		<ui:define name="metadata"></ui:define> <!-- Inclui devido ao post anterior... -->
		<ui:define name="nomeSistema">
			<h2>Testando template..."</h2>
		</ui:define>
	</ui:composition>
</h:body>
</html>

Porem, quando eu acesso a pagina comun.xhtml no browser, não aparece “Testando template…” e sim “Default nomeSistema”.

Já tentei deixar o arquivo comun.xhtml somente com o ui:composition movendo as declarações xmlns da tag html para a mesma, porem, o resultado foi o mesmo…

Alguém pode me ajudar a descobrir o que eu estou fazendo de errado?

E

eu estava com o mesmo problema, consegui resolver apenas trocando o final da minha URL. estava usando algo do tipo: http://exemplo/pasta/pagina.xhtml e troquei por: http://exemplo/pasta/pagina.jsf

Criado 9 de novembro de 2012
Ultima resposta 7 de abr. de 2015
Respostas 6
Participantes 4