[
http://jira.jboss.com/jira/browse/JBSEAM-1262?page=comments#action_12360924 ]
Keith Naas commented on JBSEAM-1262:
------------------------------------
We solved this by customizing the decorate tag. For each of the processXxx methods, we
setup, call the real method, and tear it down. In the setup we simply put the
"label" into the request map. The teardown removes it.
The label is either an attribute that the user puts into the decorate element, or if
unspecified defaults to the id of the UIComponent.
This way, when the resource bundle is accessed by the validator, it will plug the label
string into it. This works well regardless of which technology we use.
For instance our bundle looks like this.
# Please note that these override the defaults set by the JSF implementation
## BEGIN JSF override
javax.faces.converter.BigDecimalConverter.DECIMAL=#{label} is not a valid entry.
javax.faces.converter.BigDecimalConverter.DECIMAL_detail=*
javax.faces.validator.DoubleRangeValidator.MINIMUM=#{label} must be greater than or equal
to {0}.
javax.faces.validator.DoubleRangeValidator.MINIMUM_detail=*
javax.faces.validator.DoubleRangeValidator.MAXIMUM=#{label} must be less than or equal to
{0}.
javax.faces.validator.DoubleRangeValidator.MAXIMUM_detail=*
....
## END JSF Override
## Begin Hibernate Validator override
validator.assertFalse=#{label} is not a valid entry.
validator.length=#{label} must be between {min} and {max} characters.
validator.max=#{label} must be less than or equal to {value}.
validator.min=#{label} must be greater than or equal to {value}.
....
## End Hibernate Validator override
Should be able to customize Hibernate validation messages based on
context (by page, or role like Seam component scopes)
------------------------------------------------------------------------------------------------------------------------
Key: JBSEAM-1262
URL:
http://jira.jboss.com/jira/browse/JBSEAM-1262
Project: JBoss Seam
Issue Type: Feature Request
Affects Versions: 1.2.1.GA
Reporter: Nathaniel Stoddard
Currently, each validation specified a single message resource to be used as the error
message. It would be helpful if there was some way to customize the error messages to be
used such that in one case "Contact address is required." is displayed, while in
others "Billing address is required", for example. Annotating model classes
with validation rules limits the reuse of those classes since the validation messages
offer limited flexibility.
Since validated fields in the domain classes aren't necessarily associated with a
UIInput on a page, it would be helpful to have more flexible annotations, such as:
@MaxLength(messages = {@Message(role='contactForm',
value='contact.too_long'), @Message(role='billingForm',
value='billing.too_long')})
private String field;
Also needed would be some way of indicated to the UIView which 'role' should be
used when validation takes place.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira