GeeCON Prague 2014*
The moose likes JSF and the fly likes Facelets custom tag not recognized ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » JSF
Bookmark "Facelets custom tag not recognized ? " Watch "Facelets custom tag not recognized ? " New topic
Author

Facelets custom tag not recognized ?

Sim Kim
Ranch Hand

Joined: Aug 06, 2004
Posts: 268
Hi All,

I have a problem using custom tag with facelets .

My web.xml is :

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" 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-app_2_5.xsd">
<context-param>
<param-name>com.sun.faces.verifyObjects</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>com.sun.faces.validateXml</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.xhtml</param-value>
</context-param>
<context-param>
<param-name>facelets.DEVELOPMENT</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<param-name>facelets.SKIP_COMMENTS</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>facelets.LIBRARIES</param-name>
<param-value>
/WEB-INF/ticker.taglib.xml
</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>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>forward.jsp</welcome-file>
</welcome-file-list>

</web-app>

faces-config.xml

<?xml version='1.0' encoding='UTF-8'?>
<faces-config version="1.2"
xmlns="http://java.sun.com/xml/ns/javaee"
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_1_2.xsd">

<component>
<component-type>ticker</component-type>
<component-class>ticker.UITicker</component-class>
</component>

<application>
<view-handler>
com.sun.facelets.FaceletViewHandler
</view-handler>
</application>

</faces-config>

ticker.tld :

<?xml version="1.0" encoding="UTF-8"?>
<taglib xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"
version="2.0">

<description>a</description>
<tlib-version>1.0</tlib-version>
<short-name>d</short-name>
<uri>http://jsftutorials.com/</uri>
<tag>
<name>ticker</name>
<tag-class>ticker.TickerTag</tag-class>
<body-content>JSP</body-content>
</tag>
</taglib>

ticker.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:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:d="http://jsftutorials.com/"
xmlns:f="http://java.sun.com/jsf/core">
<body>
<ui:composition template="/template.xhtml">
<ui:define name="body">
<f:view>
<d:ticker>
Hello JSF Component
</d:ticker>
</f:view>
</ui:define>
</ui:composition>
</body>
</html>

ticker.taglib.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>http://jsftutorials.com/</namespace>
<tag>
<tag-name>ticker</tag-name>
<handler-class>ticker.TickerTag</handler-class>
<component>
<component-type>ticker</component-type>
</component>
</tag>
</facelet-taglib>

When the ticker.xhtml page is rendered on browser , the source code is seen like this:

<?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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Facelets - Template Example</title>
<link href="./css/default.css" rel="stylesheet" type="text/css" />
</head>

<body>
<h1>Default Title
</h1>
<p>
<d:ticker>
Hello JSF Component
</d:ticker>
</p>
</body>

</html>

It means that facelets is not recognizing the ticker tag . What is the problem ?
[ July 26, 2008: Message edited by: SIM KIM ]
Venkat Sadasivam
Ranch Hand

Joined: May 10, 2008
Posts: 139
You may need to include faces-config.xml as well in facelets.LIBRARIES parameter.


“Any fool can write code that a computer can understand. Good programmers write code that humans can understand. ”<br>
-Martin Fowler
 
GeeCON Prague 2014
 
subject: Facelets custom tag not recognized ?