O'Reilly logo

JavaServer Faces by Hans Bergsten

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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.

Example 6-1. Initial filtering criteria form JSP page (expense/stage1/filterArea.jsp)
<%@ 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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required