April 2004
Intermediate to advanced
606 pages
20h 4m
English
Let’s improve the filtering
criteria
form by binding the fields to
properties of the ReportHandler class. Example 6-3 shows the new filtering criteria page with the
value binding expressions added.
<%@ 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:messages layout="table" /><h:form> From: <h:inputText size="8"value="#{reportHandler.from}"/> <br> To: <h:inputText size="8"value="#{reportHandler.to}" /> <br> Status: <h:selectManyCheckboxvalue="#{reportHandler.status}"><f:selectItem itemValue="1" itemLabel="Open" /> <f:selectItem itemValue="2" itemLabel="Submitted" /> <f:selectItem itemValue="3" itemLabel="Accepted" /> <f:selectItem itemValue="4" itemLabel="Rejected" /> </h:selectManyCheckbox> <p> <h:commandButton value="Filter" /> </h:form> </f:view>
The value attributes for the input components
contain value binding expressions that point to the corresponding
properties in a ReportHandler instance available
through a variable named reportHandler. If you run
this page, you’ll see that the default dates
returned by the getFrom() and getTo(
) methods shown in Example 6-2 end up in
the input fields, and the same goes for the default choices returned
by the getStatus() method.
Read now
Unlock full access