0

Hi folks I am in very strange problem.I have created a client template facelet and template facelet.but when i run my web page it will not insert the defined tag.I mean not working.Here is my code
insert.xhtml:

<html xmlns="http://www.w3.org/1999/xhtml"
  xmlns:ui="http://java.sun.com/jsf/facelets">
<head>
   <title>facelet example </title>
</head>
<body> 
  <ui:insert name="face1"> </ui:insert>
  <ui:insert name="face2"> </ui:insert>
  <ui:insert name="face3"> </ui:insert>
  <ui:insert name="face4"> </ui:insert>
</body>
</html>

compose.xhtml:

<!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">
<body>
   <ui:composition template="insert.xhtml">
   <ui:define name="face1">
   <center><h2>Facelet</h2></center>
   <h3>Welcome to the Facelet world..........</h3>
  </ui:define>
  <ui:define name="face2">Enter UserID :<br/>
   <h:inputText id="it" /><br/><br/>
   </ui:define>
   <ui:define name="face3">Enter Password :<br/>
   <h:inputSecret id="is" /><br/><br/>
   </ui:define>
  <ui:define name="face4">
   <h:commandButton id="b" value="Submit" />
  </ui:define>
   </ui:composition>
</body>
</html>

but when i use <include src="compose.xhtml"> tag in insert.xhtml then it shows the complete facelet.But include tag only works if i write like this

<insert name="face1">
<include src="compose.xhtml"/>
</insert>

if I remove insert tag before include then include also don't work.I am sick from this strange behaviour of JSF 2.0 facelets.Please help me
Thanks

khan
  • 2,664
  • 8
  • 38
  • 64

2 Answers2

0

Try to follow this tutorial, it is very helpful if you are new to JSF 2 templates. Here is the link.

I think the problem is in the path of the template you are trying to use :

<ui:composition template="insert.xhtml">

should be :

<ui:composition template="/insert.xhtml">

if the template is in the root folder.

Jamil
  • 1
  • 1
0

First of all you need to understand that in tag "template" attribute is optional so it means there is a little mistake in your code.As you know that facelet will include only portion between tag so

xmlns="http://www.w3.org/1999/xhtml" 
   xmlns:ui="http://java.sun.com/jsf/facelets" 
  xmlns:h="http://java.sun.com/jsf/html"

this should come with composition not with in html tag.
Your question resembles to this question.I hope this will also help you.
Thanks

Community
  • 1
  • 1
William
  • 163
  • 4
  • 18