Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Facelets custom tag not working ?

843844Jul 26 2008 — edited Aug 4 2008
Hi I have created a ticker example using custom tags :

web.xml
<?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>
When I view the page on the browser, the source code of ticker.xhtml is shown as :
<?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>
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>
It means that facelets is not recognizing the ticker tag . What is the issue ?

Edited by: Lavjeet on Jul 26, 2008 4:04 AM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 1 2008
Added on Jul 26 2008
4 comments
432 views