Add an error message for the <f: validateLength> tag configured for the field

I have many fields on a witch, I have to check the length. This is not a problem with the <f:validateLength> . I can also add a special message for this validator.

The problem is that the message must be configured for each field. For instance. The firstname field should contain the message “ firstname name too short” or “ firstname name too long”, surname should have “too short last name” or “Last name too long”, etc. How to achieve this in JSF2.0?

+4
source share
1 answer

Use the label attribute.

 <h:inputText label="First name"> 

{1} in the message template will be replaced by this.

 javax.faces.validator.LengthValidator.MAXIMUM: {1} too long. javax.faces.validator.LengthValidator.MINIMUM: {1} too short. 
+5
source

All Articles