0

I am new to XHTMLs, I require some help regarding validation messages . when I tried to validate the user controls on client side, getting the error message in full form like

createUser:user: Validation Error: Value is required.
createUser:firstName: Validation Error: Value is required.

The validation part I am using

<h:inputText id="user" value="#{createUser.userName}" required="true">
<f:validateLength minimum="1" maximum="15"></f:validateLength></h:inputText>
<h:message for="user" style="color:red" />

Is it possible to display the error message part alone (Value is required) using client side validations alone?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Sriram
  • 19
  • 1
  • 1
  • 6

1 Answers1

0

You can customize error messages in JSF. You can look this page.

http://www.mkyong.com/jsf2/customize-validation-error-message-in-jsf-2-0/

Zapateus
  • 516
  • 3
  • 8
  • 21
  • Hi, I am still getting the default error message. – Sriram Jun 10 '13 at 11:16
  • Can you show your code, message.properties and your faces-config xml – Zapateus Jun 10 '13 at 11:18
  • Message.properties javax.faces.validator.LengthValidator.MINIMUM=Minimum length of ''{0}'' is required. javax.faces.validator.LengthValidator.MAXIMUM={1}: Length is greater than allowable maximum of ''{0}'' – Sriram Jun 10 '13 at 12:07
  • hi, sorry i didn't know to place the code in format in this page... – Sriram Jun 10 '13 at 12:09
  • Ok no problem. In message.properties you show me Length validator. In this case you should change javax.faces.component.UIInput.REQUIRED message like "javax.faces.component.UIInput.REQUIRED = Value is Required". – Zapateus Jun 10 '13 at 12:11
  • when required="true" this mesage show--> javax.faces.component.UIInput.REQUIRED if you want to validateLength minimum this message javax.faces.validator.LengthValidator.MINIMUM, if you want to lenght maximum javax.faces.validator.LengthValidator.MAXIMUM so also you should change for lenghth validator maximum and minumum like javax.faces.validator.LengthValidator.MINIMUM = Length is greater than allowable maximum of {0} and javax.faces.validator.LengthValidator.MAXIMUM = Length is greater than allowable maximum of ''{0}''. – Zapateus Jun 10 '13 at 12:39
  • Becauuse you change .LengthValidator.MINIMUM , you should change LengthValidator.MAXIMUM for max length – Zapateus Jun 10 '13 at 12:44
  • Hi, I have changed the MAXIMUM validator code . the problem was i was using ':' instead of = javax.faces.validator.LengthValidator.MAXIMUM={1}: Length is greater than allowable maximum of ''{0}'' later i changed to javax.faces.validator.LengthValidator.MAXIMUM=Length is greater than allowable maximum of ''{0}'' Also required="true" validation was overriding the min/max validations. I removed them. Thanks a lot for your pateience and help... – Sriram Jun 11 '13 at 04:05