Primefaces (com e sem) Facelets

Bom dia amigos do GUJ, estou aprendendo sobre facelets e me deparei com uma situação estranha. Implementei um cadastro de clientes utilizando primefaces sem facelets e funcionou tranquilamente. Quando o implementei com facelets tive problemas, não renderiza os recursos do primefaces acho.

Segue abaixo os códigos.

Cadastro como componente do facelets:

[code]<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:p=“http://primefaces.prime.com.tr/ui”>

<ui:composition template="/facelets/layout.xhtml">
<ui:define name=“content”>

   &lt;p:growl showDetail="true" id="msg" /&gt;
&lt;h:form prependId="false"&gt;
	&lt;p:panel header="Cadastro de Cliente"&gt;
		&lt;h:panelGrid columns="2"&gt;
		Nome: &lt;p:inputText value="#{cadastroClienteMB.cliente.nome}" size="50" id="nome"/&gt;
		Tipo: &lt;p:inputText value="#{cadastroClienteMB.cliente.tipo}" size="50" id="tipo"/&gt;
		CPF: &lt;p:inputText value="#{cadastroClienteMB.cliente.cpf}" size="50" id="cpf"/&gt;
		CNPJ: &lt;p:inputText value="#{cadastroClienteMB.cliente.cnpj}" size="50" id="cnpj"/&gt;
		Sexo: &lt;p:inputText value="#{cadastroClienteMB.cliente.sexo}" size="50" id="sexo"/&gt;
		
		
			&lt;p:commandButton value="Calcelar" action="#{cadastroClienteMB.cancelar}" update="msg, nome, tipo, cpf, cnpj, sexo, tabela"/&gt;
			&lt;p:commandButton value="Salvar" action="#{cadastroClienteMB.salvar}" update="msg, nome, tipo, cpf, cnpj, sexo, tabela"/&gt;
		&lt;/h:panelGrid&gt;
	&lt;/p:panel&gt;
&lt;/h:form&gt;
   
   
&lt;/ui:define&gt;

</ui:composition>
</html>
[/code]

Cadastro como xhtml normal:

[code]<!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:f=“http://java.sun.com/jsf/core
xmlns:p=“http://primefaces.prime.com.tr/ui”>

<h:head>
</h:head>

<h:body>
<p:fieldset legend=“Cadastro de Clientes”>
<p:growl showDetail=“true” id=“msg” />
<h:form prependId=“false”>
<p:panel header=“Cadastro de Cliente”>
<h:panelGrid columns=“2”>
Nome: <p:inputText value="#{cadastroClienteMB.cliente.nome}" size=“50” id=“nome”/>
Tipo: <p:inputText value="#{cadastroClienteMB.cliente.tipo}" size=“50” id=“tipo”/>
CPF: <p:inputText value="#{cadastroClienteMB.cliente.cpf}" size=“50” id=“cpf”/>
CNPJ: <p:inputText value="#{cadastroClienteMB.cliente.cnpj}" size=“50” id=“cnpj”/>
Sexo: <p:inputText value="#{cadastroClienteMB.cliente.sexo}" size=“50” id=“sexo”/>

			&lt;p:commandButton value="Calcelar" action="#{cadastroClienteMB.cancelar}" update="msg, nome, tipo, cpf, cnpj, sexo, tabela"/&gt;
			&lt;p:commandButton value="Salvar" action="#{cadastroClienteMB.salvar}" update="msg, nome, tipo, cpf, cnpj, sexo, tabela"/&gt;
		&lt;/h:panelGrid&gt;
	&lt;/p:panel&gt;
	&lt;/h:form&gt;	
&lt;/p:fieldset&gt;

</h:body>

</html>[/code]

É um cadastro fictício, apenas para aprendizado, o qual tentarei implementar as devidas as máscaras e validações depois… Mas com facelets. Alguém sabe como faço para que o cadastro com facelets fique igual o sem facelets?

Desde já muito obrigado :slight_smile:

cara,

poste a pagina layout.xhtml tbm.

t+

Como está o arquivo: layout.xhtml?

Está assim:

[code]<!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:f=“http://java.sun.com/jsf/core
xmlns:p=“http://primefaces.prime.com.tr/ui”>
<head>
<title>
<ui:insert name=“title”>Default title</ui:insert>
</title>
</head>

<body>

<div id=“header”>
<ui:insert name=“header”>
<ui:include src=“header.xhtml”/>
</ui:insert>
</div>

<div id=“header2”>
<ui:insert name=“header2”>
<ui:include src=“header2.xhtml”/>
</ui:insert>
</div>

<div id=“content”>
<ui:insert name=“content”>
<div>
<ui:include src=“content.xhtml”/>
</div>
</ui:insert>
</div>

<div id=“footer”>
<ui:insert name=“footer”>
<ui:include src=“footer.xhtml”/>
</ui:insert>
</div>

</body>

</html>
[/code]

Troca de para <h:head> e faz o mesmo com o passa para <h:body>.

não é necessário definir a tag ui:define para os demais?

ali voce colocou apenas o do content…

Muito obrigado!

Deu certo apenas colocando os h: nas tags head e body.

Quanto aos define, está funcionando assim, vamos ver até onde.

Que falta de atenção… :frowning:

faz assim,

<!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:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.prime.com.tr/ui">
	<head>
	  <title>
		<ui:insert name="title">Default title</ui:insert>
	  </title>
	</head>

	<body>

		<div id="header">
			<ui:include src="header.xhtml"/>
		</div>

		<div id="header2">
			<ui:include src="header2.xhtml"/>
		</div>

		<div id="content">
			<ui:insert name="content"/>
		</div>

		<div id="footer">
			<ui:include src="footer.xhtml"/> 
		</div>

	</body>

</html>
<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:f="http://java.sun.com/jsf/core"  
    xmlns:p="http://primefaces.prime.com.tr/ui"
	template="/facelets/layout.xhtml">  
    <ui:define name="content">  
            
       <p:growl showDetail="true" id="msg" />  
    <h:form prependId="false">  
        <p:panel header="Cadastro de Cliente">  
            <h:panelGrid columns="2">  
            Nome: <p:inputText value="#{cadastroClienteMB.cliente.nome}" size="50" id="nome"/>  
            Tipo: <p:inputText value="#{cadastroClienteMB.cliente.tipo}" size="50" id="tipo"/>  
            CPF: <p:inputText value="#{cadastroClienteMB.cliente.cpf}" size="50" id="cpf"/>  
            CNPJ: <p:inputText value="#{cadastroClienteMB.cliente.cnpj}" size="50" id="cnpj"/>  
            Sexo: <p:inputText value="#{cadastroClienteMB.cliente.sexo}" size="50" id="sexo"/>  
              
              
                <p:commandButton value="Calcelar" action="#{cadastroClienteMB.cancelar}" update="msg, nome, tipo, cpf, cnpj, sexo, tabela"/>  
                <p:commandButton value="Salvar" action="#{cadastroClienteMB.salvar}" update="msg, nome, tipo, cpf, cnpj, sexo, tabela"/>  
            </h:panelGrid>  
        </p:panel>  
    </h:form>  
         
         
    </ui:define>  
</ui:composition> 

T+

[quote=AitonDMT]Muito obrigado!

Deu certo!

Que falta de atenção… :frowning: [/quote]
Relaxa, acontece. [=

As vezes estamos tão presos a algumas coisas que não percebemos alguns detalhes. [=

e quando as tags <h: head> e <h:body> estão colocadas e o primefaces não funciona, o que pode ser ?

Abre um tópico, posta seu código que a gente analisa. ^^