Creating custom taglib on JSF 2.1



I'm trying to create a custom taglib to use it on some projects. When I try to use it on the project, it works well. If I put the WAR in other projects, NetBeans detect its namespace and values, but when page is rendered, it throws:



"Warning: This page calls for XML namespace http://test.com/test declared with prefix te but no taglibrary exists for that namespace."



The code is based on some blogs I've found. Here is the "taglib project" structure:



WEB-INF
--componentes
\--outputText.xhtml
--test.taglib.xhtml
--web.xml


web.xml



<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://ift.tt/nSRXKP" xmlns:xsi="http://ift.tt/ra1lAU"
xsi:schemaLocation="http://ift.tt/nSRXKP http://ift.tt/1eWqHMP">
<context-param>
<param-name>javax.faces.FACELETS_LIBRARIES</param-name>
<param-value>/WEB-INF/test.taglib.xml</param-value>
</context-param>
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</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>*.xhtml</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>index.xhtml</welcome-file>
</welcome-file-list>


test.taglib.xml



<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE facelet-taglib PUBLIC
"-//Sun Microsystems, Inc.//DTD Facelet Taglib 1.0//EN"
"http://ift.tt/MXNj6k">
<facelet-taglib version="2.0" xmlns="http://ift.tt/nSRXKP"
xmlns:xsi="http://ift.tt/ra1lAU"
xsi:schemaLocation="http://ift.tt/nSRXKP http://ift.tt/1sZaJv1">
<namespace>http://ift.tt/17ARqj8;
<tag>
<tag-name>outputText</tag-name>
<source>componentes/outputText.xhtml</source>
<attribute>
<description>Valor</description>
<name>value</name>
</attribute>
<attribute>
<description>Establece negrita</description>
<name>negrita</name>
<type>java.lang.Boolean</type>
</attribute>
</tag>


outputText.xhtml "hello world" example



<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html xmlns="http://ift.tt/lH0Osb"
xmlns:h="http://ift.tt/HjFrZb"
xmlns:ui="http://ift.tt/KsEgXx">

<ui:composition>
<h:outputText value="#{value}" style="#{negrita ? 'font-weight: bold' : '' }"/>
</ui:composition>


Using taglib (on both "taglib project" and "taglib tester project" is the same):



<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://ift.tt/kkyg93">
<html xmlns="http://ift.tt/lH0Osb"
xmlns:h="http://ift.tt/HjFrZb"
xmlns:te="http://test.com/test"
>
<h:head>
<title>Pruebas componentes</title>
</h:head>
<h:body>
<te:outputText value="Prueba te" negrita="true"/>
</h:body>


Any ideas?


No comments:

Post a Comment