Facelets - Problemas com templates [RESOLVIDO]

1 resposta
brucsantos

Bom dia!
Na minha aplicação eu tenho dois templates distintos. Um para quando o usuario não está logado e e o outro quando está.
Meu problema e o seguinte. Quando faço os inserts de paginas no template externo funciona normal, mais quando o usuario se loga e eu uso o outro template as paginas não são inclusas!

Segue os dois templates:

Externo - usuario não logado

<?xml version="1.0" encoding="ISO-8859-1"?>  
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"    
      xmlns:ui="http://java.sun.com/jsf/facelets">    
 
      
<f:loadBundle basename="messages" var="message" />

<head>	
	<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> 
    <link href="./styles/hibernate-jsf.css" rel="stylesheet" type="text/css" />  
	
</head>
<body>
	<table class="table_template" cellpadding="0" cellspacing="0">
		<thead>
			<tr>
				<td>
					<ui:insert name="external_header">Header</ui:insert>  											
				</td>
			</tr>
		</thead>
		<tbody>
			<tr>
				<td align="center" class="td_body">
					<ui:insert name="external_body">Body</ui:insert> 					
				</td>	
			</tr>
		</tbody>
		<tfoot>
			<tr>
				<td>	
					<ui:insert name="footer">Footer</ui:insert>									
				</td>
			</tr>
		</tfoot>
	</table>
</body>	
</html>

Template interno - Usuario Logado

<?xml version="1.0" encoding="ISO-8859-1"?>  
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" 	 
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets">
      
      
<f:loadBundle basename="messages" var="message" />

<head>		
	<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> 
    <link href="../styles/hibernate-jsf.css" rel="stylesheet" type="text/css" />  
</head>
<body>
	<table class="table_template" cellpadding="0" cellspacing="0" border="1">
		<thead>
			<tr>
				<td colspan="2">								
					<ui:insert name="internal_header">Header</ui:insert>
				</td>
			</tr>
			<tr>
				<td colspan="2">					
					<table width="100%">
						<tr>
							<td align="left">
								<h:outputText value="#{accessControl.login}" />
							</td>
							<td align="right">
								<a href="../pages/change_password.jsf">
									<h:outputText value="#{message.link_trocaSenha}" />
								</a>
							</td>
							<td align="right">	
								<a href="#" jscfc="h:commandLink" action="#{loginForm.logout}">
									#{message.link_logout}
								</a>							
							</td>
						</tr>
					</table>					
				</td>				
			</tr>
		</thead>
		<tbody>
			<tr>
				<td>
					<ui:insert name="menu_lateral">Menu</ui:insert>									
			    </td>	
			    <td class="td_body">
			    	<ui:insert name="internal_body">Body</ui:insert>
			    </td>		
									
			</tr>
		</tbody>
		<tfoot>
			<tr>
				<td colspan="2">	
					<ui:insert name="footer">Footer</ui:insert>
				</td>
			</tr>
		</tfoot>
	</table>	
</body>	
</html>

E essa e a minha tela interna onde usuo o ui:composition

<?xml version="1.0" encoding="ISO-8859-1"?>  
<!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:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:e="http://myfaces.apache.org/extensions"
      xmlns:t="http://myfaces.apache.org/tomahawk">

	<ui:composition template="/templates/layout_internal.xhtml">		
		<h:form>	
					
			<ui:define name="internal_header">
				<ui:include src="../includes/header.xhtml" />	
			</ui:define>
			
			<ui:define name="menu_lateral">
				<ui:include src="../includes/menu_lateral.xhtml" />	
			</ui:define>
			
			<ui:define name="internal_body">
				<table>
					<thead class="table_header">
						<tr>
							<th>
							   	Welcome 
							</th>
						</tr>					
					</thead>
					<tbody>
						<tr>
							<td>
								Teste
							</td>
						</tr>
					</tbody>
					<tfoot>
						<tr>
							<td>
							</td>
						</tr>
					</tfoot>
				</table>
			</ui:define>	
				
			<ui:define name="footer">
				<ui:include src="../includes/footer.xhtml" />
			</ui:define>	
			
		</h:form>					
	</ui:composition>

</html>

Não sei oq está errado ou se falta alguma configuração…
Obrigado,

1 Resposta

brucsantos

Bom se alguem tiver o mesmo problema…

<ui:composition template="/templates/layout_internal.xhtml">        
         <h:form>    
                       
             <ui:define name="internal_header">  
                 <ui:include src="../includes/header.xhtml" />   
             </ui:define>  
               
             <ui:define name="menu_lateral">  
                <ui:include src="../includes/menu_lateral.xhtml" />     
             </ui:define>  
               
             <ui:define name="internal_body">  
                 <table>

logo depois da minha tag ui:composition tenho a teg <h:form>
Parece que assim ele se perde todo! Apenas retirei o forme e colocoque dentro de um ui:define ficando assim

<ui:composition template="/templates/layout_internal.xhtml">                
                       
             <ui:define name="internal_header">  
                 <ui:include src="../includes/header.xhtml" />   
             </ui:define>  
               
             <ui:define name="menu_lateral">  
                <ui:include src="../includes/menu_lateral.xhtml" />     
             </ui:define>  
               
             <ui:define name="internal_body">  
                 <h:form>    
                     <table>

Abraços

Criado 4 de junho de 2009
Ultima resposta 4 de jun. de 2009
Respostas 1
Participantes 1