David Friedman wrote:
I think you need to have at least Struts v1.2.8 unless you manually upgraded
the Commons Validator jar up to version 1.2.0.  If I understand correctly,
validator versions before 1.2.0 (Struts < 1.2.8) don't actually make use of
the "bundle" attribute in your validator xml files.

So, what version of Struts are you using (1.1.4?) and/or what version of the
Commons Validator are you using?  Have you tried replacing the commons
validator jar?  I think I read that some people have tried that for older
versions but I'm not positive.
Another issue is that the FieldChecks class is a part of Struts (1.2.9) and not the commons validator. The line where I would assume it should grab it from the resources bundle doesn't contain any resource references:

   /**
* Checks if the field's length is less than or equal to the maximum value.
    *  A <code>Null</code> will be considered an error.
    *
    * @param  bean     The bean validation is being performed on.
* @param va The <code>ValidatorAction</code> that is currently being performed. * @param field The <code>Field</code> object associated with the current
    *      field being validated.
* @param errors The <code>ActionMessages</code> object to add errors to if any
    *      validation errors occur.
    * @param validator The <code>Validator</code> instance, used to access
    *      other field values.
    * @param  request  Current request object.
    * @return True if stated conditions met.
    */
   public static boolean validateMaxLength(Object bean,
                                           ValidatorAction va, Field field,
                                           ActionMessages errors,
                                           Validator validator,
                                           HttpServletRequest request) {

       String value = null;
       if (isString(bean)) {
           value = (String) bean;
       } else {
value = ValidatorUtils.getValueAsString(bean, field.getProperty());
       }

       if (value != null) {
           try {
int max = Integer.parseInt(field.getVarValue("maxlength")); // <---- RIGHT HERE

               if (!GenericValidator.maxLength(value, max)) {
errors.add(field.getKey(), Resources.getActionMessage(validator, request, va, field));

                   return false;
               }
           } catch (Exception e) {
errors.add(field.getKey(), Resources.getActionMessage(validator, request, va, field));
               return false;
           }
       }

       return true;
   }


So it's looking like I'm going to need to write my own validator. OH well....

- Scott

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to