Java Reference
In-Depth Information
If a user attempts to submit a form with one or more required fields missing, an error
message is automatically generated.
The error message is generated by the
<h:message>
tag corresponding to the
invalid field. The string
First Name
in the error message corresponds to the value
of the
label
attribute for the field. Had we omitted the
label
attribute, the value
of the field's
id
attribute would have been shown instead. As we can see, the
required
attribute makes it very easy to implement mandatory field functionality
in our application.
Recall that the
age
field is bound to a property of type
Integer
in our named bean.
If a user enters a value that is not a valid integer into this field, a validation error is
automatically generated.