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://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_3_0.xsd">
<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>
</web-app>
test.taglib.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE facelet-taglib PUBLIC
"-//Sun Microsystems, Inc.//DTD Facelet Taglib 1.0//EN"
"http://java.sun.com/dtd/facelet-taglib_1_0.dtd">
<facelet-taglib version="2.0" 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-facelettaglibrary_2_0.xsd">
<namespace>http://test.com/test</namespace>
<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>
</facelet-taglib>
outputText.xhtml "hello world" example
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets">
<ui:composition>
<h:outputText value="#{value}" style="#{negrita ? 'font-weight: bold' : '' }"/>
</ui:composition>
</html>
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://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
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>
</html>
Any ideas?