How to correctly use jsf and primeface templates

Asked

Viewed 203 times

-1

I made a template and called it inside another page, but what I apply on the second page does not work. In index.xhtml I write a phrase to test, but it is not printed on the screen. Only the template is rendered.

I’m using a Maven project with primeface 6.0 and jsf 2.2.16.

//xhtml template.



xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui"
xmlns:ui="http://java.sun.com/jsf/facelets">

<h:head>  
<title>PROJETO MUSICANDO</title>  
</h:head>  

<h:body>  

</h:body>  
</html>  

//index.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:h="http://java.sun.com/jsf/html"  
xmlns:f="http://java.sun.com/jsf/core"  
xmlns:p="http://primefaces.org/ui"  
xmlns:ui="http://java.sun.com/jsf/facelets">  

<!-- importa o template -->  
<ui:composition template="/template.xhtml"/>  

<!-- essa frase não aparece quando digito localhost:8080/webmusicos/faces/index.xhtml -->   
<h:outputText value="Bem-vindo ao projeto musicando"/>  


</html>  

1 answer

0

Content on the index page must be inside the Composition tag.

//xhtml template.



xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui"
xmlns:ui="http://java.sun.com/jsf/facelets">

<h:head>  
<title>PROJETO MUSICANDO</title>  
</h:head>  

<h:body>  

</h:body>  
</html>  

//index.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:h="http://java.sun.com/jsf/html"  
xmlns:f="http://java.sun.com/jsf/core"  
xmlns:p="http://primefaces.org/ui"  
xmlns:ui="http://java.sun.com/jsf/facelets">  

<!-- importa o template -->  
<ui:composition template="/template.xhtml">  

<h:outputText value="Bem-vindo ao projeto musicando"/>  

</ui:composition>

</html>  

Browser other questions tagged

You are not signed in. Login or sign up in order to post.