Navigation Rule, Template, Primefaces

1 resposta
silver00

Pessoal, minhas páginas não estão redirecionando, e mesmo que eu tire as regras do faces-config, pelo menos a página de login é redirecionada, mas não sei como, pois não mando fazer nenhum redirecionamento fora do faces-config.

Não sei como funciona o redirecionamento com templates, acho que fiz errado.

Hierarquia de paginas:

WebContent>pages>public>homePage
===================> login
===================>cadastro
========>resources>template>template

faces-config
<?xml version="1.0" encoding="UTF-8"?>
<faces-config version="2.0" xmlns="http://java.sun.com/xml/ns/javaee"
 xmlns:xi="http://www.w3.org/2001/XInclude"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
 xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd">
 

 <navigation-rule>
	<from-view-id>/resources/template/default.xhtml</from-view-id>
	<navigation-case>
		<from-outcome>cadastro</from-outcome>
		<to-view-id>/pages/public/cadastroProfile.xhtml</to-view-id>
		<redirect />
	</navigation-case>
	<navigation-case>
		<from-outcome>login</from-outcome>
		<to-view-id>/pages/public/login.xhtml</to-view-id>
		<redirect />
	</navigation-case>
</navigation-rule>


 <navigation-rule>
	<from-view-id>/pages/public/login.xhtml</from-view-id>	
	<navigation-case>
		<from-outcome>voltar</from-outcome>
		<to-view-id>/pages/public/homePage.xhtml</to-view-id>
		<redirect />
	</navigation-case>
</navigation-rule>

</faces-config>
template
<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:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">
 
    <h:head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <title>Certificado Digital</title>
        <style type="text/css">
            body {background-color: #8B8989; font-size: 12px}
        </style> 
    </h:head>
    <h:body>
        <div align="center">
            <p:layout style="min-width:1000px;max-width:1028px;min-height:600px">  <!-- Tamano geral da Página -->
                <p:layoutUnit position="north" size="278" rendered="true">  <!-- Cabeçalho -->
                    <h:graphicImage url="/resources/template/imagens/top_banner.jpg" width="1020" height="264"/>
                </p:layoutUnit>  
                
                <p:layoutUnit position="west" size="220">  
                    <ui:insert name="menu">
                        <h:form>
                            <p:menu style="width: 200px">
                                <p:submenu label="Menu">
                                    <p:menuitem value="Login" icon="ui-icon-key"  action="login"/>
                                    <p:menuitem value="Fazer meu cadastro" icon="ui-icon-contact" action="cadastro"/>         
                                </p:submenu>
                            </p:menu>
                        </h:form>
                    </ui:insert>
                </p:layoutUnit> 
                 
                <p:layoutUnit position="center">  
                    <ui:insert name="centro">
                        O que estiver aqui será substituido!
                    </ui:insert>
                </p:layoutUnit>  
            </p:layout>  
        </div>
    </h:body>
</html>
homePage
<!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:p="http://primefaces.org/ui"> 

<ui:decorate template="/resources/template/default.xhtml">
        <ui:define name="centro">
        	<p>Bem Vindos!</p>
        </ui:define>
</ui:decorate>
</html>
login
<!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:p="http://primefaces.org/ui"> 

<ui:decorate template="/resources/template/default.xhtml">
        <ui:define name="centro">
        	<form method="post" action="j_security_check">
	        	<p:panelGrid columns="2">
		            <h:outputLabel for="j_username" value="Username"/>
		            <p:inputText id="j_username" name="j_username" />
		            
		            <h:outputLabel for="j_password" value="Password" />
		            <p:password type="password" id="j_password" name="j_password" />
		            
		            <p:commandButton value="Login" type="submit" name="submit" />          
		       		<p:commandButton value="Voltar" action="voltar" immediate="true" />
        		</p:panelGrid>        
    		</form> 
        </ui:define>
</ui:decorate>
</html>
cadastro
<html xmlns="http://www.w3.org/1999/xhtml"  
      xmlns:h="http://java.sun.com/jsf/html" 
      xmlns:p="http://primefaces.org/ui"  
      xmlns:f="http://java.sun.com/jsf/core">  
        
<h:head>  
    <title>Cadastro e Emissão de Certificado</title>  
</h:head>  
  
<h:body>    
    <h:form id="cadastro"> 
    	<p:panel id="painelCadastro" header="Novo Cadastro" style="margin-bottom:10px;">         
	    	<p:messages id="messages" autoUpdate="true" closable="true" />   
	        	                      
		      
	   		
	   		                        
	   	</p:panel>       
    </h:form>  
</h:body>  
</html>

1 Resposta

silver00

Ninguém?

Criado 4 de abril de 2013
Ultima resposta 5 de abr. de 2013
Respostas 1
Participantes 1