Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Facelet will not render

Status
Not open for further replies.

jem122974

Programmer
Nov 1, 2001
114
US
I have done a couple projects using JSF and facelets, but it has been awhile since I set up a new one from scratch. I think I have all the pieces in place but the facelet will not render. Can anyone tell me what I am missing? The last piece of code is the resulting HTML page. The <application:signIn></application:signIn> line is where the facelet is supposed to render, but some link must be missing.

Thank you in advance!
Jon

faces-config.xml
XML:
<!DOCTYPE faces-config PUBLIC
  "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.0//EN"
  "[URL unfurl="true"]http://java.sun.com/dtd/web-facesconfig_1_0.dtd">[/URL]

<faces-config>

	<application>
    	<locale-config>
    	  <default-locale>en</default-locale>
	    </locale-config>
		<view-handler>com.sun.facelets.FaceletViewHandler</view-handler>
	</application>
	
	<!-- Navigation Forwarding -->
	<navigation-rule>
		<from-view-id>/signIn.jsf</from-view-id>
		<navigation-case>
			<description></description>
			<from-outcome>success</from-outcome>
			<to-view-id>/signIn.jsf</to-view-id>
		</navigation-case>
		<navigation-case>
			<description></description>
			<from-outcome>retry</from-outcome>
			<to-view-id>/signIn.jsf</to-view-id>
		</navigation-case>
	</navigation-rule>	
	
</faces-config>

web.xml
XML:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="[URL unfurl="true"]http://www.w3.org/2001/XMLSchema-instance"[/URL] xmlns="[URL unfurl="true"]http://java.sun.com/xml/ns/javaee"[/URL] xmlns:web="[URL unfurl="true"]http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"[/URL] xsi:schemaLocation="[URL unfurl="true"]http://java.sun.com/xml/ns/javaee[/URL] [URL unfurl="true"]http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"[/URL] id="WebApp_ID" version="3.0">
  <display-name>TicketingAdmin</display-name>
  <welcome-file-list>
    <welcome-file>signIn.jsf</welcome-file>
  </welcome-file-list>

  <context-param>
    <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
    <param-value>.jsf</param-value>
  </context-param>
  <servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.jsf</url-pattern>
  </servlet-mapping>

  <context-param>
    <param-name>javax.faces.FACELETS_LIBRARIES</param-name>
    <param-value>
      /WEB-INF/facelets/tags/application.taglib.xml
    </param-value>
  </context-param>

</web-app>

template.jsf
HTML:
<html xmlns:jsp="[URL unfurl="true"]http://java.sun.com/JSP/Page"[/URL]
	xmlns:ui="[URL unfurl="true"]http://java.sun.com/jsf/facelets"[/URL]
	xmlns:f="[URL unfurl="true"]http://java.sun.com/jsf/core"[/URL]
	xmlns:h="[URL unfurl="true"]http://java.sun.com/jsf/html"[/URL]
	version="2.0">

	<body>	

<ui:composition>	
<html>
	<head>
		<title>
			<ui:insert name="title">Ticketing System</ui:insert>
		</title>	
		<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
		<ui:insert name="stylesheet"></ui:insert>
	</head>
	<body>
	<f:view>
	
    <div id="UI" class="userInterface">
        <div id="Hdr_UI" class="header">
            <h1 class="title"><ui:insert name="uiTitle">Ticketing System</ui:insert></h1>
            <div class="logo"></div>
            
            <div id="Loader" class="loader" style="display:none;">
            	<div id="Ldr_Text" class="data datLoaderText">Loading...</div>
            </div>
            
            <span class="tagLine"><ui:insert name="uiTagLine">Facility name goes here</ui:insert></span>
            
            <div class="navigation">
            </div>
        </div>
		<ui:insert name="uiApplications"></ui:insert>	
        <div id="Ftr_UI" class="footer">
        	<ui:insert name="uiFooter"></ui:insert>
        </div>
	</div>		
		
		<ui:insert name="uiScriptModels"></ui:insert>	
		<ui:insert name="uiScriptBehaviors"></ui:insert>	
	</f:view>

	</body>
</html>	
</ui:composition>
	
	</body>
</html>

signIn.jsf (facelet)
HTML:
<html xmlns:jsp="[URL unfurl="true"]http://java.sun.com/JSP/Page"[/URL]
	xmlns:c="[URL unfurl="true"]http://java.sun.com/jstl/core"[/URL]
	xmlns:ui="[URL unfurl="true"]http://java.sun.com/jsf/facelets"[/URL]
	xmlns:f="[URL unfurl="true"]http://java.sun.com/jsf/core"[/URL]
	xmlns:h="[URL unfurl="true"]http://java.sun.com/jsf/html"[/URL]
	version="2.0">
	<body>

<ui:composition>

    <div id="App_SignIn" class="application">
        <div id="PV_Application" class="module panelView">
            <div class="header">
                <h2 class="title">Ticketing Administration</h2>
            </div>
            <div id="Cnt_Main" class="content">
            	Sign in here...
            </div>
            <div class="footer"></div>
        </div>
        <div id="Frozen_App_Ticketing" class="frozen" style="display:none;"></div>
    </div>
	
</ui:composition>	

	</body>
</html>

application.taglib.xml
XML:
<?xml version="1.0"?>
<!DOCTYPE facelet-taglib PUBLIC
  "-//Sun Microsystems, Inc.//DTD Facelet Taglib 1.0//EN"
  "facelet-taglib_1_0.dtd">
<facelet-taglib>
	<namespace>[URL unfurl="true"]http://ej.com/mf/application</namespace>[/URL]
	<tag>
		<tag-name>signIn</tag-name>
		<source>application/signIn.jsf</source>
	</tag>
</facelet-taglib>

signIn.jsf (main page)
HTML:
<html xmlns:jsp="[URL unfurl="true"]http://java.sun.com/JSP/Page"[/URL]
	xmlns:ui="[URL unfurl="true"]http://java.sun.com/jsf/facelets"[/URL]
	xmlns:f="[URL unfurl="true"]http://java.sun.com/jsf/core"[/URL]
	xmlns:h="[URL unfurl="true"]http://java.sun.com/jsf/html"[/URL]
	xmlns:c="[URL unfurl="true"]http://java.sun.com/jstl/core"[/URL]
	xmlns:application="[URL unfurl="true"]http://ej.com/mf/application"[/URL]
	version="2.0">

	<body>	

<ui:composition template="/WEB-INF/application/template.jsf">

	<ui:define name="uiTagLine">
	</ui:define>
	<ui:define name="uiScriptModels">
	</ui:define>
	<ui:define name="uiScriptBehaviors">
	</ui:define>
	
	<application:signIn />	
	<ui:define name="uiApplications">
		<application:signIn />	
	</ui:define>

</ui:composition>

	</body>
</html>

Resulting page
HTML:
<html>
	<head>
		<title>Ticketing System
		</title>	
		<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
	</head>
	<body>
	
    <div id="UI" class="userInterface">
        <div id="Hdr_UI" class="header">
            <h1 class="title">Ticketing System</h1>
            <div class="logo"></div>
            
            <div id="Loader" class="loader" style="display:none;">
            	<div id="Ldr_Text" class="data datLoaderText">Loading...</div>
            </div>
            
            <span class="tagLine"></span>
            
            <div class="navigation">
            </div>
        </div>
		<application:signIn></application:signIn>	
        <div id="Ftr_UI" class="footer">
        </div>
	</div>

	</body>
</html>
 
I found my problem, or problems. The funny thing is now I'm not sure how my current projects are working!

First problem was my taglib.xml couldn't be found. I simply had it in the wrong folder. Once I moved it to the correct place I got past the rendering problem.

Then I got the following error:
javax.servlet.ServletException: PWC1232: Exceeded maximum depth for nested request dispatches: 20

After researching this awhile I found that I didn't have things configured right.

First, in my faces-config.xml I needed to change my opening tag and comment out the view-handler:
XML:
<?xml version="1.0" encoding="UTF-8"?>
<faces-config 
   xmlns="[URL unfurl="true"]http://java.sun.com/xml/ns/javaee"[/URL]  
   xmlns:xsi="[URL unfurl="true"]http://www.w3.org/2001/XMLSchema-instance"[/URL]  
   xsi:schemaLocation="[URL unfurl="true"]http://java.sun.com/xml/ns/javaee[/URL] [URL unfurl="true"]http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"[/URL] 
   version="2.0">
	
	<!-- 
	<application>
    	<locale-config>
    	  <default-locale>en</default-locale>
	    </locale-config>
		<view-handler>com.sun.facelets.FaceletViewHandler</view-handler>
	</application>
	-->

Then in my web.xml I needed to change my default suffix to .xhtml
XML:
  <context-param>
    <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
    <param-value>.xhtml</param-value>
  </context-param>

And finally I had to rename my main page signIn.jsf to signIn.xhtml. Then viola, it worked!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top