Java Reference
In-Depth Information
in the HTML_BASIC TLD, available at
http://docs.oracle.com/javaee/6/
The TLD file name must end with
taglib.xml
. In the Duke's Bookstore case study,
the
custom
tags
area
and
map
are
defined
in
the
file
web/WEB-INF/book-
store.taglib.xml
.
All tag definitions must be nested inside the
facelet-taglib
element in the TLD.
Each tag is defined by a
tag
element that specifies a particular combination of a compon-
ent type and a renderer type. Here are the tag definitions for the
area
and
map
compon-
ents:
<facelet-taglib xmlns="http://java.sun.com/xml/ns/javaee"
... >
<namespace>http://dukesbookstore</namespace>
<tag>
<tag-name>area</tag-name>
<component>
<component-type>DemoArea</component-type>
<renderer-type>DemoArea</renderer-type>
</component>
</tag>
<tag>
<tag-name>map</tag-name>
<component>
<component-type>DemoMap</component-type>
<renderer-type>DemoMap</renderer-type>
</component>
</tag>
</facelet-taglib>
The
component-type
element specifies the name defined in the
@FacesCompon-
ent
annotation, while the
renderer-type
element specifies the
rendererType
defined in the
@FacesRenderer
annotation.
The
facelet-taglib
element must also include a
namespace
element, which
defines the namespace to be specified in pages that use the custom component. See “
Using
a Custom Component
”
on page
121
for information on specifying the namespace in pages.
The TLD file is located in the
WEB-INF
directory. In addition, an entry is included in the
web deployment descriptor (
web.xml
) to identify the custom tag library descriptor file,
as follows: