Using JSF Components in a JSP Page
The JSP page for the initial version of the filtering criteria form is shown in Example 6-1.
<%@ page contentType="text/html" %><%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<f:view>
<h:form>
From:<h:inputText size="8" />
<br> To:<h:inputText size="8" />
<br> Status:<h:selectManyCheckbox>
<f:selectItem itemValue="1" itemLabel="Open" />
<f:selectItem itemValue="2" itemLabel="Submitted" />
<f:selectItem itemValue="3" itemLabel="Accepted" />
<f:selectItem itemVvalue="4" itemLabel="Rejected" />
</h:selectManyCheckbox>
<p><h:commandButton value="Filter" />
</h:form>
</f:view>
The page starts with a JSP page
directive, saying
that the page generates HTML, and two taglib
directives that
declare
the tag libraries used in the page. Each taglib
directive contains two attributes: the uri
attribute specifies the unique identifier for the library and the
prefix
attribute defines the namespace prefix used
for elements from the library in this page. Note that even though the
uri
attribute value looks like a URL, it doesn’t mean that the tag library is accessed over the Internet when you run the page. It’s just a string that uniquely identifies a specific library, and a URL is typically used for public libraries because it’s a pretty good guarantee that it won’t clash with the identifier ...
Get JavaServer Faces now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.