7 Replies Latest reply on Feb 9, 2009 7:40 AM by 807575

    Customizing validation messages

      I'm using JSC 2 Early Access 2 on Win XP.
      I'm working on a small app and I want to customize the validation messages for the REQUIRED validation.
      I'm using the default Bundle resource file.
      I put a text field (with the required property set to true) and a inline message next to it (linked with the for property)
      If I run the app and intentionally leave the text field blank I got the error mesage "Validation error: value is required" which is good.
      Later I added this key to the Bundle properties file: javax.faces.component.UIInput.REQUIRED and set the value for a simple "Required"
      When I run the app again I still got the "Validation error: value is required" message instead of the simple "Required".
      I followed the simple tutorial at:
      but I keep getting the same message.
      Please help me with this problem!
        • 1. Re: Customizing validation messages
          Just checking, Did you edit the faces-config.xml to add this properties file as message-bundle?
          Also, You might want to check out the same tutorial updated for EA2

          Let us know if you still have any issues.
          • 2. Re: Customizing validation messages
            The proyect's name is "epro"

            I modified the faces-config.xml and in the application section I wrote:


            But this didn't work.
            • 3. Re: Customizing validation messages
              Could you please ensure that you don't have any trailing spaces in properties.key for javax.faces.component.UIInput.REQUIRED?

              Also, make sure that you have uncommented the <application> block in faces-config.xml, which is pre-commented when the project is created.

              Let us know, if you still have issues.

              • 4. Re: Customizing validation messages
                I feel terrible sorry! yes the <application> section was commented!
                I un-commented it and it worked fine!
                Thanks for your help guys!
                • 5. Re: Customizing validation messages
                  Hello Sakthi,

                  i want to use german Standard Validation Errors via a own .properties File:
                  Here is my faces-config.xml ( the entries are uncommented ! ):
                  Here is mymessages.properties-File in package alles:
                  javax.faces.validator.NOT_IN_RANGE=Das angegebene Attribut liegt nicht zwischen den erwarteten Werten {0} und {1}.
                  javax.faces.validator.NOT_IN_RANGE_detail="{2}"\:Eingegebener Wert liegt nicht im erwarteten Bereich von {0} bis {1}.
                  javax.faces.validator.LongRangeValidator.LIMIT_detail=Eingegebener Wert kann nicht in den korrekten Typ umgewandelt werden.
                  javax.faces.validator.LongRangeValidator.MAXIMUM_detail="{1}"\:Wert ist gr\u00F6\u00DFer als das erlaubte Maximum"{0}".
                  Here the part of the JSF-View with the Validator:
                  <ui:textField binding="#{WorkTypeEdit.textFieldBeschartKzSoll}" converter="#{WorkTypeEdit.bigIntegerConverter1}"
                  id="textFieldBeschartKzSoll" required="true" style="height: 24px; width: 48px" validator="#{WorkTypeEdit.longRangeValidator1.validate}"/>

                  The application still shows the standard englisch validation error text. What is wrong here ?
                  I' am using NetBeans 5.5.1 with VWP and the deploment is to Glassfish server.

                  Thanks a lot.
                  • 6. Re: Customizing validation messages
                    Try to use this.

                    javax.faces.validator.DoubleRangeValidator.NOT_IN_RANGE=Error: El valor no está entre los valores esperados de {0} y {1}
                    • 7. Re: Customizing validation messages
                      Try to use this

                      javax.faces.validator.LongRangeValidator.NOT_IN_RANGE=Error: El valor no está entre los valores esperados de {0} y {1}