The required
attribute lets you specify whether a value
must be supplied for a UIInput component or a component that extends
UIInput. If a component must have a non-null value or a String value of
at least one character, set the required
attribute to true.
You can use the required
attribute with nested validators
on the same component.
When the form is submitted and the value is null or a zero-length string, the component is invalidated and an error message is placed in the queue. If there are other validators registered on the component, they are not called at all and the current page is redisplayed.
Note: If you do not use a required
attribute and set it to true, other validators that are registered on
the component are called. If the component must have a value, then you
have to handle null or zero-length strings in those validators.
When a page has a required input field and a command component say, a
"Cancel" button, a validation error will cause the current page to
redisplay if the user clicks "Cancel" without filling in a value in the
required field. In that case, you need to set the immediate
attribute of the command component to true, thereby allowing the command
to be executed during the Apply Request Values phase.
About Conversion and Validation Errors
About the Conversion and Validation Process in JSF
Using Converters and Validators in JSF
Copyright © 1997, 2004, Oracle. All rights reserved.