A taglib descriptor in JSF is a taglib.xml.
Name the taglib descriptor always start with a word and follow by "taglib.xml", eg. kian.taglib.xml
taglib descriptor allowed us to define our custom namespace, convertor, validator, composite component, and facelets function.
more details about taglib descriptor could be found here.
Steps:
1. Create a file named "kian.taglib.xml" in WEB-INF folder. the word kian could be replaced with any preferred word.
2. Specify the path of the taglib.xml in web.xml to load it during startup.
the one-time configuration is done, now we can use the configured namespace in xhml.
Done!!
Name the taglib descriptor always start with a word and follow by "taglib.xml", eg. kian.taglib.xml
taglib descriptor allowed us to define our custom namespace, convertor, validator, composite component, and facelets function.
more details about taglib descriptor could be found here.
Steps:
1. Create a file named "kian.taglib.xml" in WEB-INF folder. the word kian could be replaced with any preferred word.
<facelet-taglib 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"
version="2.0">
<namespace>http://kian/jsf/composite/cc</namespace>
<composite-library-name>kian</composite-library-name>
</facelet-taglib>
note: the red highlighted url is the namespace to be used in xhtml to reference this taglib.2. Specify the path of the taglib.xml in web.xml to load it during startup.
<context-param>
<param-name>facelets.LIBRARIES</param-name>
<param-value>/WEB-INF/kian.taglib.xml</param-value>
</context-param>
note: more than 1 taglib.xml could be added, simply separate it with a semicolon(;)the one-time configuration is done, now we can use the configured namespace in xhml.
<f:view
xmlns="http://www.w3.org/1999/xhtml"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:kian="http://kian/jsf/composite/cc">
...........................................
...........................................
</f:view>
Done!!
No comments:
Post a Comment