When a conversion or validation error occurs, the component whose conversion or validation failed places an error message in the queue and invalidates itself. After the Process Validations phase, JSF redisplays the current page.
To let the user know what caused the conversion or validation error, you
need to display the error message next to the component that generated
the message. To do this, you must assign an ID to the component. Then
use the h:message
tag next to the component, referencing
the component's ID in the tag's for
attribute. You can
specify whether to display a detail message (default) or a summary
message.
If you want to change the text of the standard converter message, you
can set up a message bundle and supply the replacement text for the
conversion failed message, using the key
javax.faces.component.UIInput.CONVERSION
.
[can you do the same for validation errors? what is the key for validation?]
Note: It is possible but uncommon for a component to
report more than one message. In this unlikely event, the h:message
tag shows only the first message generated by the component. For debugging
purposes, use the h:messages
tag on a page to see all
messages generated by all components.
About the Conversion and Validation
Process in JSF
Displaying a
Conversion or Validation Error Message
Copyright © 1997, 2004, Oracle. All rights reserved.