Hi all,

I am using Struts 2 annotations for validation:

    @Validations(requiredStrings = {
                    @RequiredStringValidator(fieldName = "firstName", type =
ValidatorType.FIELD, message = "First name is required"),
                    @RequiredStringValidator(fieldName = "lastName", type =
ValidatorType.FIELD, message = "Last name is required"),
                    @RequiredStringValidator(fieldName = "email", type =
ValidatorType.FIELD, message = "Email is required")
                 },
                 emails = {
                    @EmailValidator(fieldName = "email", type =
ValidatorType.FIELD, message = "Email format is incorrect")
                 },
                 intRangeFields = {
                    @IntRangeFieldValidator(fieldName = "itemSelectedId",
type = ValidatorType.FIELD, min = "1", shortCircuit = true, message = "An
item is required")
                 }
    )
    public String save() throws Exception
..

This works fine for all the fields except for the IntRangeFieldValidator. It
inserts the javascript code twice instead of one only:

// field name: itemSelectedId
       // validator name: int
       if (form.elements['itemSelectedId']) {
           field = form.elements['itemSelectedId'];
           var error = "An itemis required";
           if (continueValidation && field.value != null) {
               if (parseInt(field.value) <
                    1 ||
                       false) {
                   addError(field, error);
                   errors = true;
                   continueValidation = false;
               }
           }
       }

Consequently, the error message is also displayed twice !
Any idea on what could cause this ?

Thanks in advance,
PBR

Reply via email to