April 2004
Intermediate to advanced
606 pages
20h 4m
English
The expense report entry form part of the sample application contains a number of fields that require validation: all fields must have a value, a syntactically valid date must be entered in the Date field, and the Amount field must contain an amount larger than one. Figure 7-1 shows all these fields, with a couple of error messages, generated by the initial implementation of this form.
![]() |
The JSP file for this version of the form is shown in Example 7-2.
<%@ 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>
Title:
<h:inputText id="title" size="30" required="true"
value="#{reportHandler.currentReport.title}" />
<h:message for="title" />
<br>
Entry:
<br>
Date:
<h:inputText id="date" size="8" required="true"
value="#{entryHandler.currentEntry.date}">
<f:convertDateTime dateStyle="short" />
</h:input_text>
<h:message for="date" />
<br>
Type:
<h:selectOneMenu id="type" required="true"
value="#{entryHandler.currentEntry.type}">
<f:selectItems value="#{entryHandler.expenseTypeChoices}"/>
</h:selectOneMenu>
<h:message for="type" />
<br>
Amount:
<h:inputText id="amount" size="8" required="true" ...Read now
Unlock full access