public class JsfLabelMessageInterpolator extends Object implements javax.validation.MessageInterpolator
{jsf.label}
can be used. This MessageInterpolator
will replace every occurrence of that with the label of the
current component.
Note that Bean Validation is not only called from within JSF, and as such JSF might not be available. If JSF
is not available occurrences of {jsf.label}
will be replaced by "nothing" (the empty string).
The user should take care that messages are compatible with both situations if needed.
This message interpolator is NOT needed for putting a component label before or after a bean validation
message. That functionality is already provided by JSF itself via the javax.faces.validator.BeanValidator.MESSAGE
key in any resource bundle known to JSF.
ValidationMessages.properties
javax.validation.constraints.Size.message = The size of {jsf.label} must be between {min} and {max} characters
META-INF/validation.xml
file with the following contents:
<?xml version="1.0" encoding="UTF-8"?> <validation-config xmlns="http://jboss.org/xml/ns/javax/validation/configuration" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jboss.org/xml/ns/javax/validation/configuration validation-configuration-1.0.xsd"> <message-interpolator>org.omnifaces.validator.JsfLabelMessageInterpolator</message-interpolator> </validation-config>
Constructor and Description |
---|
JsfLabelMessageInterpolator() |
Modifier and Type | Method and Description |
---|---|
String |
interpolate(String messageTemplate,
javax.validation.MessageInterpolator.Context context) |
String |
interpolate(String messageTemplate,
javax.validation.MessageInterpolator.Context context,
Locale locale) |
Copyright © 2012–2014 OmniFaces. All rights reserved.