Add error message for <f:validateLength> tag customised for a field
I have many fields on witch I have to validate length. It's not a problem with <f:validateL开发者_运维知识库ength>
tag. I can also add custom message for this validator.
The problem is the message should be customised for each field. E.g. firstname
field should have messages "First name too short" or "First name too long", surname
should have "Surname too short" or "Surname too long" etc. How to achieve that in JSF2.0?
Use the label
attribute.
<h:inputText label="First name">
The {1}
in the message template will be substituted with this.
javax.faces.validator.LengthValidator.MAXIMUM: {1} too long.
javax.faces.validator.LengthValidator.MINIMUM: {1} too short.
精彩评论