Java Reference
In-Depth Information
<context-param>
<param-name>javax.faces.FACELETS_LIBRARIES</param-name>
<param-value>/WEB-INF/bookstore.taglib.xml</param-value>
</context-param>
Using a Custom Component
To use a custom component in a page, you add the custom tag associated with the com-
ponent to the page.
As explained in “
Defining the Custom Component Tag in a Tag Library Descriptor
”
on
application if you intend to use the tags in your pages. TLD files are stored in the
WEB-
INF/
directory or subdirectory of the WAR file or in the
META-INF/
directory or sub-
directory of a tag library packaged in a JAR file.
You also need to include a namespace declaration in the page so that the page has access
to the tags. The custom tags for the Duke's Bookstore case study are defined in
book-
store.taglib.xml
. The
ui:composition
tag on the
index.xhtml
page de-
clares the namespace defined in the tag library:
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:bookstore="http://dukesbookstore"
template="./bookstoreTemplate.xhtml">
Finally, to use a custom component in a page, you add the component's tag to the page.
The Duke's Bookstore case study includes a custom image map component on the
in-
dex.xhtml
page. This component allows you to select a book by clicking on a region
of the image map:
...
<h:graphicImage id="mapImage"
name="book_all.jpg"
library="images
alt="#{bundle.chooseLocale}"
usemap="#bookMap" />
<bookstore:map id="bookMap"