rleland     2002/10/17 18:35:02

  Modified:    conf/share validator-rules.xml
               src/share/org/apache/struts/taglib/html
                        JavascriptValidatorTag.java
               src/share/org/apache/struts/util StrutsValidator.java
                        StrutsValidatorUtil.java
               src/share/org/apache/struts/validator
                        DynaValidatorActionForm.java DynaValidatorForm.java
                        ValidatorActionForm.java ValidatorForm.java
  Log:
  Duplicate & rename Validator classes in util to validator package.
  StrutsValidator -> ValidatorChecks
  StrutsValidatorUtils->Resources
  Make depreciated classes depend on renamed classes.
  Modify JavDoc to document this change.
  
  Revision  Changes    Path
  1.11      +18 -18    jakarta-struts/conf/share/validator-rules.xml
  
  Index: validator-rules.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/conf/share/validator-rules.xml,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- validator-rules.xml       16 Oct 2002 18:44:30 -0000      1.10
  +++ validator-rules.xml       18 Oct 2002 01:35:02 -0000      1.11
  @@ -41,7 +41,7 @@
      <global>
   
         <validator name="required"
  -            classname="org.apache.struts.util.StrutsValidator"
  +            classname="org.apache.struts.validator.ValidatorChecks"
                  method="validateRequired"
            methodParams="java.lang.Object,
                          org.apache.commons.validator.ValidatorAction,
  @@ -82,7 +82,7 @@
         </validator>
   
         <validator name="requiredif"
  -                 classname="org.apache.struts.util.StrutsValidator"
  +                 classname="org.apache.struts.validator.ValidatorChecks"
                    method="validateRequiredIf"
                    methodParams="java.lang.Object,
                                  org.apache.commons.validator.ValidatorAction,
  @@ -94,7 +94,7 @@
         </validator>
   
         <validator name="minlength"
  -            classname="org.apache.struts.util.StrutsValidator"
  +            classname="org.apache.struts.validator.ValidatorChecks"
                  method="validateMinLength"
            methodParams="java.lang.Object,
                          org.apache.commons.validator.ValidatorAction,
  @@ -136,7 +136,7 @@
   
   
         <validator name="maxlength"
  -            classname="org.apache.struts.util.StrutsValidator"
  +            classname="org.apache.struts.validator.ValidatorChecks"
                  method="validateMaxLength"
            methodParams="java.lang.Object,
                          org.apache.commons.validator.ValidatorAction,
  @@ -178,7 +178,7 @@
   
   
         <validator name="mask"
  -            classname="org.apache.struts.util.StrutsValidator"
  +            classname="org.apache.struts.validator.ValidatorChecks"
                  method="validateMask"
            methodParams="java.lang.Object,
                          org.apache.commons.validator.ValidatorAction,
  @@ -229,7 +229,7 @@
   
   
         <validator name="byte"
  -            classname="org.apache.struts.util.StrutsValidator"
  +            classname="org.apache.struts.validator.ValidatorChecks"
                  method="validateByte"
            methodParams="java.lang.Object,
                          org.apache.commons.validator.ValidatorAction,
  @@ -274,7 +274,7 @@
   
   
         <validator name="short"
  -            classname="org.apache.struts.util.StrutsValidator"
  +            classname="org.apache.struts.validator.ValidatorChecks"
                  method="validateShort"
            methodParams="java.lang.Object,
                          org.apache.commons.validator.ValidatorAction,
  @@ -320,7 +320,7 @@
   
   
         <validator name="integer"
  -            classname="org.apache.struts.util.StrutsValidator"
  +            classname="org.apache.struts.validator.ValidatorChecks"
                  method="validateInteger"
            methodParams="java.lang.Object,
                          org.apache.commons.validator.ValidatorAction,
  @@ -366,7 +366,7 @@
   
   
         <validator name="long"
  -            classname="org.apache.struts.util.StrutsValidator"
  +            classname="org.apache.struts.validator.ValidatorChecks"
                  method="validateLong"
            methodParams="java.lang.Object,
                          org.apache.commons.validator.ValidatorAction,
  @@ -378,7 +378,7 @@
   
   
         <validator name="float"
  -            classname="org.apache.struts.util.StrutsValidator"
  +            classname="org.apache.struts.validator.ValidatorChecks"
                  method="validateFloat"
            methodParams="java.lang.Object,
                          org.apache.commons.validator.ValidatorAction,
  @@ -424,7 +424,7 @@
   
   
         <validator name="double"
  -            classname="org.apache.struts.util.StrutsValidator"
  +            classname="org.apache.struts.validator.ValidatorChecks"
                  method="validateDouble"
            methodParams="java.lang.Object,
                          org.apache.commons.validator.ValidatorAction,
  @@ -436,7 +436,7 @@
   
   
         <validator name="date"
  -            classname="org.apache.struts.util.StrutsValidator"
  +            classname="org.apache.struts.validator.ValidatorChecks"
                  method="validateDate"
            methodParams="java.lang.Object,
                          org.apache.commons.validator.ValidatorAction,
  @@ -599,7 +599,7 @@
   
   <!-- range is deprecated use rangeInt instead -->
         <validator name="range"
  -            classname="org.apache.struts.util.StrutsValidator"
  +            classname="org.apache.struts.validator.ValidatorChecks"
                  method="validateIntRange"
            methodParams="java.lang.Object,
                          org.apache.commons.validator.ValidatorAction,
  @@ -610,7 +610,7 @@
                     msg="errors.range">
   
            <javascript><![CDATA[
  -            function validateRange(form) {               
  +            function validateRange(form) {
                   return validIntRange(form);
               }]]>
            </javascript>
  @@ -618,7 +618,7 @@
         </validator>
   
         <validator name="intRange"
  -            classname="org.apache.struts.util.StrutsValidator"
  +            classname="org.apache.struts.validator.ValidatorChecks"
                  method="validateIntRange"
            methodParams="java.lang.Object,
                          org.apache.commons.validator.ValidatorAction,
  @@ -662,7 +662,7 @@
         </validator>
   
         <validator name="floatRange"
  -            classname="org.apache.struts.util.StrutsValidator"
  +            classname="org.apache.struts.validator.ValidatorChecks"
                  method="validateFloatRange"
            methodParams="java.lang.Object,
                          org.apache.commons.validator.ValidatorAction,
  @@ -706,7 +706,7 @@
         </validator>
   
         <validator name="creditCard"
  -            classname="org.apache.struts.util.StrutsValidator"
  +            classname="org.apache.struts.validator.ValidatorChecks"
                  method="validateCreditCard"
            methodParams="java.lang.Object,
                          org.apache.commons.validator.ValidatorAction,
  @@ -784,7 +784,7 @@
   
   
         <validator name="email"
  -            classname="org.apache.struts.util.StrutsValidator"
  +            classname="org.apache.struts.validator.ValidatorChecks"
                  method="validateEmail"
            methodParams="java.lang.Object,
                          org.apache.commons.validator.ValidatorAction,
  
  
  
  1.7       +5 -6      
jakarta-struts/src/share/org/apache/struts/taglib/html/JavascriptValidatorTag.java
  
  Index: JavascriptValidatorTag.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/JavascriptValidatorTag.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- JavascriptValidatorTag.java       16 Oct 2002 20:55:07 -0000      1.6
  +++ JavascriptValidatorTag.java       18 Oct 2002 01:35:02 -0000      1.7
  @@ -78,7 +78,7 @@
   import org.apache.struts.action.Action;
   import org.apache.struts.validator.ValidatorPlugIn;
   import org.apache.struts.util.MessageResources;
  -import org.apache.struts.util.StrutsValidatorUtil;
  +import org.apache.struts.validator.Resources;
   import org.apache.struts.util.RequestUtils;
   import org.apache.struts.config.ApplicationConfig;
   
  @@ -357,7 +357,7 @@
                       // Skip indexed fields for now until there is
                       // a good way to handle error messages (and the length of the 
list (could retrieve from scope?))
                       if (!field.isIndexed() && field.getPage() == page && 
field.isDependency(va.getName())) {
  -                        String message = StrutsValidatorUtil.getMessage(messages, 
locale, va, field);
  +                        String message = Resources.getMessage(messages, locale, va, 
field);
                           message = (message != null ? message : "");
   
                           jscriptVar = getNextVar(jscriptVar);
  @@ -393,16 +393,15 @@
                   }
                   results.append("    } \n\n");
               }
  -        } else {
  -            results.append("<script language=\"Javascript1.1\">");
           }
   
           if ("true".equals(staticJavascript)) {
               results.append(getJavascriptStaticMethods(resources));
           }
   
  -        results.append(getJavascriptEnd());
  -
  +        if ("true".equals(dynamicJavascript)) {
  +            results.append(getJavascriptEnd());
  +        }
   
           // Print this field to our output writer
           JspWriter writer = pageContext.getOut();
  
  
  
  1.12      +31 -514   
jakarta-struts/src/share/org/apache/struts/util/StrutsValidator.java
  
  Index: StrutsValidator.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-struts/src/share/org/apache/struts/util/StrutsValidator.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- StrutsValidator.java      16 Oct 2002 18:44:30 -0000      1.11
  +++ StrutsValidator.java      18 Oct 2002 01:35:02 -0000      1.12
  @@ -56,17 +56,11 @@
   
   import java.io.Serializable;
   import java.util.Date;
  -import java.util.Locale;
   import javax.servlet.http.HttpServletRequest;
   
  -import org.apache.commons.logging.Log;
  -import org.apache.commons.logging.LogFactory;
  +
   import org.apache.commons.validator.Field;
  -import org.apache.commons.validator.GenericTypeValidator;
  -import org.apache.commons.validator.GenericValidator;
   import org.apache.commons.validator.ValidatorAction;
  -import org.apache.commons.validator.ValidatorUtil;
  -import org.apache.commons.validator.Validator;
   import org.apache.struts.action.ActionErrors;
   
   /**
  @@ -78,10 +72,11 @@
    * In general passin in a null or blank will return a null Object or a false
    * boolean. However, nulls and blanks do not result in an error being added to the
    * errors.
  + *@deprecated  As of Struts 1.1b3, replaced by    {@link 
org.apache.struts.validator.ValidatorChecks }
    *
    *@author     David Winterfeldt
    *@author     James Turner
  - *@author     Rob Leland
  +
    *@since      Struts 1.1
    */
   public class StrutsValidator implements Serializable {
  @@ -89,8 +84,6 @@
       /**
        *  Commons Logging instance.
        */
  -    private static Log LOG = LogFactory.getLog(StrutsValidator.class);
  -
       public final static String FIELD_TEST_NULL = "NULL";
       public final static String FIELD_TEST_NOTNULL = "NOTNULL";
       public final static String FIELD_TEST_EQUAL = "EQUAL";
  @@ -101,6 +94,7 @@
        *
        *  Checks if the field isn't null and length of the field is greater than zero
        *  not including whitespace.</p>
  +     *@deprecated  As of Struts 1.1b3, replaced by {@link 
org.apache.struts.validator.ValidatorChecks#validateRequired(Object,ValidatorAction,Field,ActionErrors,HttpServletRequest)}
        *
        *@param  bean     The bean validation is being performed on.
        *@param  va       The <code>ValidatorAction</code> that is currently being 
performed.
  @@ -116,119 +110,17 @@
                                              ActionErrors errors,
                                              HttpServletRequest request) {
   
  -        String value = null;
  -        if (isString(bean)) {
  -            value = (String) bean;
  -        } else {
  -            value = ValidatorUtil.getValueAsString(bean, field.getProperty());
  -        }
  -        if (GenericValidator.isBlankOrNull(value)) {
  -            errors.add(field.getKey(),
  -                                 StrutsValidatorUtil.getActionError(request, va, 
field));
  -
  -            return false;
  -        } else {
  -            return true;
  -        }
  -
  +       return 
org.apache.struts.validator.ValidatorChecks.validateRequired(bean,va,field,errors,request);
       }
   
   
  -    /**
  -     *  <p>
  -     *
  -     *  Checks if the field isn't null based on the values of other fields
  -     *  </p>
  -     *
  -     *@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>ActionErrors</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 meets stated requirements, False otherwise
  -     */
  -    public static boolean validateRequiredIf(Object bean,
  -                                             ValidatorAction va, Field field,
  -                                             ActionErrors errors,
  -                                             Validator validator,
  -                                             HttpServletRequest request) {
  -        Object form = validator.getResource(Validator.BEAN_KEY);
  -        String value = null;
  -        boolean required = false;
  -        if (isString(bean)) {
  -            value = (String) bean;
  -        } else {
  -            value = ValidatorUtil.getValueAsString(bean, field.getProperty());
  -        }
  -        int i = 0;
  -        String fieldJoin = "AND";
  -        if (!GenericValidator.isBlankOrNull(field.getVarValue("field-join"))) {
  -            fieldJoin = field.getVarValue("field-join");
  -        }
  -        if (fieldJoin.equalsIgnoreCase("AND")) {
  -            required = true;
  -        }
  -        while (!GenericValidator.isBlankOrNull(field.getVarValue("field[" + i + 
"]"))) {
  -            String dependProp = field.getVarValue("field[" + i + "]");
  -            String dependTest = field.getVarValue("field-test[" + i + "]");
  -            String dependTestValue = field.getVarValue("field-value[" + i + "]");
  -            String dependIndexed = field.getVarValue("field-indexed[" + i + "]");
  -            if (dependIndexed == null)
  -                dependIndexed = "false";
  -            String dependVal = null;
  -            boolean this_required = false;
  -            if (field.isIndexed() && dependIndexed.equalsIgnoreCase("true")) {
  -                String key = field.getKey();
  -                if ((key.indexOf("[") > -1) &&
  -                                     (key.indexOf("]") > -1)) {
  -                    String ind = key.substring(0, key.indexOf(".") + 1);
  -                    dependProp = ind + dependProp;
  -                }
  -            }
  -            dependVal = ValidatorUtil.getValueAsString(form, dependProp);
  -            if (dependTest.equals(FIELD_TEST_NULL)) {
  -                if ((dependVal != null) && (dependVal.length() > 0)) {
  -                    this_required = false;
  -                } else {
  -                    this_required = true;
  -                }
  -            }
  -            if (dependTest.equals(FIELD_TEST_NOTNULL)) {
  -                if ((dependVal != null) && (dependVal.length() > 0)) {
  -                    this_required = true;
  -                } else {
  -                    this_required = false;
  -                }
  -            }
  -            if (dependTest.equals(FIELD_TEST_EQUAL)) {
  -                this_required = dependTestValue.equalsIgnoreCase(dependVal);
  -            }
  -            if (fieldJoin.equalsIgnoreCase("AND")) {
  -                required = required && this_required;
  -            } else {
  -                required = required || this_required;
  -            }
  -            i++;
  -        }
  -        if (required) {
  -            if ((value != null) && (value.length() > 0)) {
  -                return true;
  -            } else {
  -                errors.add(field.getKey(), 
StrutsValidatorUtil.getActionError(request, va, field));
  -                return false;
  -            }
  -        }
  -        return true;
  -    }
   
       /**
        *  <p>
        *
        *  Checks if the field matches the regular expression in the field's mask 
attribute.
        *  </p>
  +     *@deprecated  As of Struts 1.1b3, replaced by {@link 
org.apache.struts.validator.ValidatorChecks#validateMask(Object,ValidatorAction,Field,ActionErrors,HttpServletRequest)}
        *
        *@param  bean     The bean validation is being performed on.
        *@param  va       The <code>ValidatorAction</code> that is currently being 
performed.
  @@ -244,29 +136,7 @@
                                          ActionErrors errors,
                                          HttpServletRequest request) {
   
  -        String mask = field.getVarValue("mask");
  -        String value = null;
  -        if (isString(bean)) {
  -            value = (String) bean;
  -        } else {
  -            value = ValidatorUtil.getValueAsString(bean,
  -                                 field.getProperty());
  -        }
  -        try {
  -            if (!GenericValidator.isBlankOrNull(value) &&
  -                                 !GenericValidator.matchRegexp(value, mask)) {
  -                errors.add(field.getKey(),
  -                                     StrutsValidatorUtil.getActionError(request, va,
  -                                                          field));
  -
  -                return false;
  -            } else {
  -                return true;
  -            }
  -        } catch (Exception e) {
  -            LOG.error(e.getMessage(), e);
  -        }
  -        return true;
  +       return 
org.apache.struts.validator.ValidatorChecks.validateMask(bean,va,field,errors,request);
       }
   
   
  @@ -274,6 +144,7 @@
        *  <p>
        *
        *  Checks if the field can safely be converted to a byte primitive.</p>
  +     *@deprecated  As of Struts 1.1b3, replaced by {@link 
org.apache.struts.validator.ValidatorChecks#validateByte(Object,ValidatorAction,Field,ActionErrors,HttpServletRequest)}
        *
        *@param  bean     The bean validation is being performed on.
        *@param  va       The <code>ValidatorAction</code> that is currently being 
performed.
  @@ -289,23 +160,7 @@
                                       ActionErrors errors,
                                       HttpServletRequest request) {
   
  -        Byte result = null;
  -        String value = null;
  -        if (isString(bean)) {
  -            value = (String) bean;
  -        } else {
  -            value = ValidatorUtil.getValueAsString(bean, field.getProperty());
  -        }
  -
  -        if (!GenericValidator.isBlankOrNull(value)) {
  -            result = GenericTypeValidator.formatByte(value);
  -
  -            if (result == null) {
  -                errors.add(field.getKey(), 
StrutsValidatorUtil.getActionError(request, va, field));
  -            }
  -        }
  -
  -        return result;
  +       return 
org.apache.struts.validator.ValidatorChecks.validateByte(bean,va,field,errors,request);
       }
   
   
  @@ -313,6 +168,7 @@
        *  <p>
        *
        *  Checks if the field can safely be converted to a short primitive.</p>
  +     *@deprecated  As of Struts 1.1b3, replaced by {@link 
org.apache.struts.validator.ValidatorChecks#validateShort(Object,ValidatorAction,Field,ActionErrors,HttpServletRequest)}
        *
        *@param  bean     The bean validation is being performed on.
        *@param  va       The <code>ValidatorAction</code> that is currently being 
performed.
  @@ -327,23 +183,7 @@
                                         ValidatorAction va, Field field,
                                         ActionErrors errors,
                                         HttpServletRequest request) {
  -        Short result = null;
  -        String value = null;
  -        if (isString(bean)) {
  -            value = (String) bean;
  -        } else {
  -            value = ValidatorUtil.getValueAsString(bean, field.getProperty());
  -        }
  -
  -        if (!GenericValidator.isBlankOrNull(value)) {
  -            result = GenericTypeValidator.formatShort(value);
  -
  -            if (result == null) {
  -                errors.add(field.getKey(), 
StrutsValidatorUtil.getActionError(request, va, field));
  -            }
  -        }
  -
  -        return result;
  +        return 
org.apache.struts.validator.ValidatorChecks.validateShort(bean,va,field,errors,request);
       }
   
   
  @@ -351,6 +191,7 @@
        *  <p>
        *
        *  Checks if the field can safely be converted to an int primitive.</p>
  +     *@deprecated  As of Struts 1.1b3, replaced by {@link 
org.apache.struts.validator.ValidatorChecks#validateInteger(Object,ValidatorAction,Field,ActionErrors,HttpServletRequest)}
        *
        *@param  bean     The bean validation is being performed on.
        *@param  va       The <code>ValidatorAction</code> that is currently being 
performed.
  @@ -365,23 +206,7 @@
                                             ValidatorAction va, Field field,
                                             ActionErrors errors,
                                             HttpServletRequest request) {
  -        Integer result = null;
  -        String value = null;
  -        if (isString(bean)) {
  -            value = (String) bean;
  -        } else {
  -            value = ValidatorUtil.getValueAsString(bean, field.getProperty());
  -        }
  -
  -        if (!GenericValidator.isBlankOrNull(value)) {
  -            result = GenericTypeValidator.formatInt(value);
  -
  -            if (result == null) {
  -                errors.add(field.getKey(), 
StrutsValidatorUtil.getActionError(request, va, field));
  -            }
  -        }
  -
  -        return result;
  +       return 
org.apache.struts.validator.ValidatorChecks.validateInteger(bean,va,field,errors,request);
       }
   
   
  @@ -389,6 +214,7 @@
        *  <p>
        *
        *  Checks if the field can safely be converted to a long primitive.</p>
  +     *@deprecated  As of Struts 1.1b3, replaced by {@link 
org.apache.struts.validator.ValidatorChecks#validateLong(Object,ValidatorAction,Field,ActionErrors,HttpServletRequest)}
        *
        *@param  bean     The bean validation is being performed on.
        *@param  va       The <code>ValidatorAction</code> that is currently being 
performed.
  @@ -403,23 +229,7 @@
                                       ValidatorAction va, Field field,
                                       ActionErrors errors,
                                       HttpServletRequest request) {
  -        Long result = null;
  -        String value = null;
  -        if (isString(bean)) {
  -            value = (String) bean;
  -        } else {
  -            value = ValidatorUtil.getValueAsString(bean, field.getProperty());
  -        }
  -
  -        if (!GenericValidator.isBlankOrNull(value)) {
  -            result = GenericTypeValidator.formatLong(value);
  -
  -            if (result == null) {
  -                errors.add(field.getKey(), 
StrutsValidatorUtil.getActionError(request, va, field));
  -            }
  -        }
  -
  -        return result;
  +        return 
org.apache.struts.validator.ValidatorChecks.validateLong(bean,va,field,errors,request);
       }
   
   
  @@ -427,6 +237,7 @@
        *  <p>
        *
        *  Checks if the field can safely be converted to a float primitive.</p>
  +     *@deprecated  As of Struts 1.1b3, replaced by {@link 
org.apache.struts.validator.ValidatorChecks#validateFloat(Object,ValidatorAction,Field,ActionErrors,HttpServletRequest)}
        *
        *@param  bean     The bean validation is being performed on.
        *@param  va       The <code>ValidatorAction</code> that is currently being 
performed.
  @@ -441,23 +252,7 @@
                                         ValidatorAction va, Field field,
                                         ActionErrors errors,
                                         HttpServletRequest request) {
  -        Float result = null;
  -        String value = null;
  -        if (isString(bean)) {
  -            value = (String) bean;
  -        } else {
  -            value = ValidatorUtil.getValueAsString(bean, field.getProperty());
  -        }
  -
  -        if (!GenericValidator.isBlankOrNull(value)) {
  -            result = GenericTypeValidator.formatFloat(value);
  -
  -            if (result == null) {
  -                errors.add(field.getKey(), 
StrutsValidatorUtil.getActionError(request, va, field));
  -            }
  -        }
  -
  -        return result;
  +       return 
org.apache.struts.validator.ValidatorChecks.validateFloat(bean,va,field,errors,request);
       }
   
   
  @@ -465,6 +260,7 @@
        *  <p>
        *
        *  Checks if the field can safely be converted to a double primitive.</p>
  +     *@deprecated  As of Struts 1.1b3, replaced by {@link 
org.apache.struts.validator.ValidatorChecks#validateDouble(Object,ValidatorAction,Field,ActionErrors,HttpServletRequest)}
        *
        *@param  bean     The bean validation is being performed on.
        *@param  va       The <code>ValidatorAction</code> that is currently being 
performed.
  @@ -479,23 +275,7 @@
                                           ValidatorAction va, Field field,
                                           ActionErrors errors,
                                           HttpServletRequest request) {
  -        Double result = null;
  -        String value = null;
  -        if (isString(bean)) {
  -            value = (String) bean;
  -        } else {
  -            value = ValidatorUtil.getValueAsString(bean, field.getProperty());
  -        }
  -
  -        if (!GenericValidator.isBlankOrNull(value)) {
  -            result = GenericTypeValidator.formatDouble(value);
  -
  -            if (result == null) {
  -                errors.add(field.getKey(), 
StrutsValidatorUtil.getActionError(request, va, field));
  -            }
  -        }
  -
  -        return result;
  +       return 
org.apache.struts.validator.ValidatorChecks.validateDouble(bean,va,field,errors,request);
       }
   
   
  @@ -510,6 +290,7 @@
        *  variable is specified, then the field gets the DateFormat.SHORT format for
        *  the locale. The setLenient method is set to <code>false</code> for all 
variations.
        *  </p>
  +     *@deprecated  As of Struts 1.1b3, replaced by {@link 
org.apache.struts.validator.ValidatorChecks#validateDate(Object,ValidatorAction,Field,ActionErrors,HttpServletRequest)}
        *
        *@param  bean     The bean validation is being performed on.
        *@param  va       The <code>ValidatorAction</code> that is currently being 
performed.
  @@ -525,36 +306,7 @@
                                       ActionErrors errors,
                                       HttpServletRequest request) {
   
  -        Date result = null;
  -        String value = null;
  -        if (isString(bean)) {
  -            value = (String) bean;
  -        } else {
  -            value = ValidatorUtil.getValueAsString(bean, field.getProperty());
  -        }
  -        String datePattern = field.getVarValue("datePattern");
  -        String datePatternStrict = field.getVarValue("datePatternStrict");
  -        Locale locale = StrutsValidatorUtil.getLocale(request);
  -
  -        if (!GenericValidator.isBlankOrNull(value)) {
  -            try {
  -                if (datePattern != null && datePattern.length() > 0) {
  -                    result = GenericTypeValidator.formatDate(value, datePattern, 
false);
  -                } else if (datePatternStrict != null && datePatternStrict.length() 
> 0) {
  -                    result = GenericTypeValidator.formatDate(value, 
datePatternStrict, true);
  -                } else {
  -                    result = GenericTypeValidator.formatDate(value, locale);
  -                }
  -            } catch (Exception e) {
  -                LOG.error(e.getMessage(), e);
  -            }
  -
  -            if (result == null) {
  -                errors.add(field.getKey(), 
StrutsValidatorUtil.getActionError(request, va, field));
  -            }
  -        }
  -
  -        return result;
  +       return 
org.apache.struts.validator.ValidatorChecks.validateDate(bean,va,field,errors,request);
       }
   
       /**
  @@ -562,7 +314,7 @@
        *
        *  Checks if a fields value is within a range (min &amp; max specified in the
        *  vars attribute).</p>
  -     *@deprecated  As of Struts 1.1b3, replaced by {@link 
#validateIntRange(Object,ValidatorAction,Field,ActionErrors,HttpServletRequest)}
  +     *@deprecated  As of Struts 1.1b3, replaced by {@link 
org.apache.struts.validator.ValidatorChecks#validateIntRange(Object,ValidatorAction,Field,ActionErrors,HttpServletRequest)}
        *@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
  @@ -576,154 +328,7 @@
                                           ValidatorAction va, Field field,
                                           ActionErrors errors,
                                           HttpServletRequest request) {
  -        return validateIntRange(bean, va, field, errors, request);
  -    }
  -
  -    /**
  -     *  <p>
  -     *
  -     *  Checks if a fields value is within a range (min &amp; max specified in the
  -     *  vars attribute).</p>
  -     *
  -     *@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>ActionErrors</code> object to add errors to if any
  -     *      validation errors occur.
  -     *@param  request  Current request object.
  -     *@return          True if in range, false otherwise.
  -     */
  -    public static boolean validateIntRange(Object bean,
  -                                           ValidatorAction va, Field field,
  -                                           ActionErrors errors,
  -                                           HttpServletRequest request) {
  -
  -        String value = null;
  -        if (isString(bean)) {
  -            value = (String) bean;
  -        } else {
  -            value = ValidatorUtil.getValueAsString(bean, field.getProperty());
  -        }
  -        String sMin = field.getVarValue("min");
  -        String sMax = field.getVarValue("max");
  -
  -        if (!GenericValidator.isBlankOrNull(value)) {
  -            try {
  -                int iValue = Integer.parseInt(value);
  -                int min = Integer.parseInt(sMin);
  -                int max = Integer.parseInt(sMax);
  -
  -                if (!GenericValidator.isInRange(iValue, min, max)) {
  -                    errors.add(field.getKey(), 
StrutsValidatorUtil.getActionError(request, va, field));
  -
  -                    return false;
  -                }
  -            } catch (Exception e) {
  -                errors.add(field.getKey(), 
StrutsValidatorUtil.getActionError(request, va, field));
  -                return false;
  -            }
  -        }
  -
  -        return true;
  -    }
  -
  -    /**
  -     *  <p>
  -     *
  -     *  Checks if a fields value is within a range (min &amp; max specified in the
  -     *  vars attribute).</p>
  -     *
  -     *@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>ActionErrors</code> object to add errors to if any
  -     *      validation errors occur.
  -     *@param  request  Current request object.
  -     *@return          True if in range, false otherwise.
  -     */
  -    public static boolean validateDoubleRange(Object bean,
  -                                              ValidatorAction va, Field field,
  -                                              ActionErrors errors,
  -                                              HttpServletRequest request) {
  -
  -        String value = null;
  -        if (isString(bean)) {
  -            value = (String) bean;
  -        } else {
  -            value = ValidatorUtil.getValueAsString(bean, field.getProperty());
  -        }
  -        String sMin = field.getVarValue("min");
  -        String sMax = field.getVarValue("max");
  -
  -        if (!GenericValidator.isBlankOrNull(value)) {
  -            try {
  -                double dValue = Double.parseDouble(value);
  -                double min = Double.parseDouble(sMin);
  -                double max = Double.parseDouble(sMax);
  -
  -                if (!GenericValidator.isInRange(dValue, min, max)) {
  -                    errors.add(field.getKey(), 
StrutsValidatorUtil.getActionError(request, va, field));
  -
  -                    return false;
  -                }
  -            } catch (Exception e) {
  -                errors.add(field.getKey(), 
StrutsValidatorUtil.getActionError(request, va, field));
  -                return false;
  -            }
  -        }
  -
  -        return true;
  -    }
  -
  -    /**
  -     *  <p>
  -     *
  -     *  Checks if a fields value is within a range (min &amp; max specified in the
  -     *  vars attribute).</p>
  -     *
  -     *@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>ActionErrors</code> object to add errors to if any
  -     *      validation errors occur.
  -     *@param  request  Current request object.
  -     *@return          True if in range, false otherwise.
  -     */
  -    public static boolean validateFloatRange(Object bean,
  -                                             ValidatorAction va, Field field,
  -                                             ActionErrors errors,
  -                                             HttpServletRequest request) {
  -
  -        String value = null;
  -        if (isString(bean)) {
  -            value = (String) bean;
  -        } else {
  -            value = ValidatorUtil.getValueAsString(bean, field.getProperty());
  -        }
  -        String sMin = field.getVarValue("min");
  -        String sMax = field.getVarValue("max");
  -
  -        if (!GenericValidator.isBlankOrNull(value)) {
  -            try {
  -                float fValue = Float.parseFloat(value);
  -                float min = Float.parseFloat(sMin);
  -                float max = Float.parseFloat(sMax);
  -
  -                if (!GenericValidator.isInRange(fValue, min, max)) {
  -                    errors.add(field.getKey(), 
StrutsValidatorUtil.getActionError(request, va, field));
  -
  -                    return false;
  -                }
  -            } catch (Exception e) {
  -                errors.add(field.getKey(), 
StrutsValidatorUtil.getActionError(request, va, field));
  -                return false;
  -            }
  -        }
  -
  -        return true;
  +        return org.apache.struts.validator.ValidatorChecks.validateIntRange(bean, 
va, field, errors, request);
       }
   
   
  @@ -731,6 +336,7 @@
        *  <p>
        *
        *  Checks if the field is a valid credit card number.</p> <p>
  +     *@deprecated  As of Struts 1.1b3, replaced by {@link 
org.apache.struts.validator.ValidatorChecks#validateCreditCard(Object,ValidatorAction,Field,ActionErrors,HttpServletRequest)}
        *
        *  Translated to Java by Ted Husted (<a 
href="mailto:husted@;apache.org">[EMAIL PROTECTED]
        *  </a>).<br>
  @@ -751,23 +357,7 @@
                                             ActionErrors errors,
                                             HttpServletRequest request) {
   
  -        Long result = null;
  -        String value = null;
  -        if (isString(bean)) {
  -            value = (String) bean;
  -        } else {
  -            value = ValidatorUtil.getValueAsString(bean, field.getProperty());
  -        }
  -
  -        if (!GenericValidator.isBlankOrNull(value)) {
  -            result = GenericTypeValidator.formatCreditCard(value);
  -
  -            if (result == null) {
  -                errors.add(field.getKey(), 
StrutsValidatorUtil.getActionError(request, va, field));
  -            }
  -        }
  -
  -        return result;
  +       return 
org.apache.struts.validator.ValidatorChecks.validateCreditCard(bean,va,field,errors,request);
       }
   
   
  @@ -775,6 +365,7 @@
        *  <p>
        *
        *  Checks if a field has a valid e-mail address.</p> <p>
  +     *@deprecated  As of Struts 1.1b3, replaced by {@link 
org.apache.struts.validator.ValidatorChecks#validateEmail(Object,ValidatorAction,Field,ActionErrors,HttpServletRequest)}
        *
        *  Based on a script by Sandeep V. Tamhankar ([EMAIL PROTECTED]), 
http://javascript.internet.com
        *  </p>
  @@ -793,19 +384,7 @@
                                           ActionErrors errors,
                                           HttpServletRequest request) {
   
  -        String value = null;
  -        if (isString(bean)) {
  -            value = (String) bean;
  -        } else {
  -            value = ValidatorUtil.getValueAsString(bean, field.getProperty());
  -        }
  -
  -        if (!GenericValidator.isBlankOrNull(value) && 
!GenericValidator.isEmail(value)) {
  -            errors.add(field.getKey(), StrutsValidatorUtil.getActionError(request, 
va, field));
  -            return false;
  -        } else {
  -            return true;
  -        }
  +       return 
org.apache.struts.validator.ValidatorChecks.validateEmail(bean,va,field,errors,request);
       }
   
   
  @@ -815,6 +394,7 @@
        *  Checks if the field's length is less than or equal to the maximum value.
        *  A <code>Null</code> will be considered an error.</p>
        *
  +     *@deprecated  As of Struts 1.1b3, replaced by {@link 
org.apache.struts.validator.ValidatorChecks#validateMaxLength(Object,ValidatorAction,Field,ActionErrors,HttpServletRequest)}
        *@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
  @@ -829,30 +409,7 @@
                                               ActionErrors errors,
                                               HttpServletRequest request) {
   
  -        String value = null;
  -        if (isString(bean)) {
  -            value = (String) bean;
  -        } else {
  -            value = ValidatorUtil.getValueAsString(bean, field.getProperty());
  -        }
  -        String sMaxLength = field.getVarValue("maxlength");
  -
  -        if (value != null) {
  -            try {
  -                int max = Integer.parseInt(sMaxLength);
  -
  -                if (!GenericValidator.maxLength(value, max)) {
  -                    errors.add(field.getKey(), 
StrutsValidatorUtil.getActionError(request, va, field));
  -
  -                    return false;
  -                }
  -            } catch (Exception e) {
  -                errors.add(field.getKey(), 
StrutsValidatorUtil.getActionError(request, va, field));
  -                return false;
  -            }
  -        }
  -
  -        return true;
  +       return 
org.apache.struts.validator.ValidatorChecks.validateMaxLength(bean,va,field,errors,request);
       }
   
   
  @@ -862,6 +419,7 @@
        *  Checks if the field's length is greater than or equal to the minimum value.
        *  A <code>Null</code> will be considered an error.</p>
        *
  +     *@deprecated  As of Struts 1.1b3, replaced by {@link 
org.apache.struts.validator.ValidatorChecks#validateMinLength(Object,ValidatorAction,Field,ActionErrors,HttpServletRequest)}
        *@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
  @@ -876,48 +434,7 @@
                                               ActionErrors errors,
                                               HttpServletRequest request) {
   
  -        String value = null;
  -        if (isString(bean)) {
  -            value = (String) bean;
  -        } else {
  -            value = ValidatorUtil.getValueAsString(bean, field.getProperty());
  -        }
  -        String sMinLength = field.getVarValue("minlength");
  -
  -        if (value != null) {
  -            try {
  -                int min = Integer.parseInt(sMinLength);
  -
  -                if (!GenericValidator.minLength(value, min)) {
  -                    errors.add(field.getKey(), 
StrutsValidatorUtil.getActionError(request, va, field));
  -
  -                    return false;
  -                }
  -            } catch (Exception e) {
  -                errors.add(field.getKey(), 
StrutsValidatorUtil.getActionError(request, va, field));
  -                return false;
  -            }
  -        }
  -
  -        return true;
  -    }
  -
  -
  -    /**
  -     *  <p>
  -     *
  -     *  Return <code>true</code> if the specified object is a String or a 
<code>null</code>
  -     *  value.</p>
  -     *
  -     *@param  o  Object to be tested
  -     *@return    The string value
  -     */
  -    private static boolean isString(Object o) {
  -
  -        if (o == null) {
  -            return (true);
  -        }
  -        return (String.class.isInstance(o));
  +        return 
org.apache.struts.validator.ValidatorChecks.validateMinLength(bean,va,field,errors,request);
       }
   
   }
  
  
  
  1.7       +21 -107   
jakarta-struts/src/share/org/apache/struts/util/StrutsValidatorUtil.java
  
  Index: StrutsValidatorUtil.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-struts/src/share/org/apache/struts/util/StrutsValidatorUtil.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- StrutsValidatorUtil.java  14 Oct 2002 16:32:59 -0000      1.6
  +++ StrutsValidatorUtil.java  18 Oct 2002 01:35:02 -0000      1.7
  @@ -64,24 +64,21 @@
   import java.util.Locale;
   import javax.servlet.ServletContext;
   import javax.servlet.http.HttpServletRequest;
  -import org.apache.struts.action.Action;
   import org.apache.struts.action.ActionError;
   import org.apache.struts.action.ActionErrors;
   import org.apache.struts.util.MessageResources;
  -import org.apache.commons.validator.Arg;
   import org.apache.commons.validator.Field;
   import org.apache.commons.validator.Validator;
   import org.apache.commons.validator.ValidatorAction;
   import org.apache.commons.validator.ValidatorResources;
  -import org.apache.struts.validator.ValidatorPlugIn;
  -import org.apache.struts.config.ApplicationConfig;
  -import org.apache.struts.Globals;
  +
   
   
   /**
    * <p>This class helps provides some useful methods for retrieving objects
    * from different scopes of the application.</p>
    *
  +{@link org.apache.struts.validator.Resources}
    * @author David Winterfeldt
    * @author Eddie Bush
    * @version $Revision$ $Date$
  @@ -104,8 +101,6 @@
      */
      public static String ACTION_ERRORS_KEY = "org.apache.struts.action.ActionErrors";
   
  -   private static Locale defaultLocale = Locale.getDefault();
  -
      /**
       * Retrieve <code>ValidatorResources</code> for the module.
       *
  @@ -114,15 +109,14 @@
       *  to get the resources for the current application module.
      */
      public static ValidatorResources getValidatorResources(ServletContext 
application) {
  -      return 
(ValidatorResources)application.getAttribute(ValidatorPlugIn.VALIDATOR_KEY);
  +       return 
org.apache.struts.validator.Resources.getValidatorResources(application);
      }
   
     /**
      * Retrieve <code>ValidatorResources</code> for the current module.
      */
      public static ValidatorResources getValidatorResources(ServletContext 
application,HttpServletRequest request) {
  -      return (ValidatorResources) 
application.getAttribute(ValidatorPlugIn.VALIDATOR_KEY +
  -                           
((ApplicationConfig)request.getAttribute(Globals.APPLICATION_KEY)).getPrefix());
  +      return 
org.apache.struts.validator.Resources.getValidatorResources(application,request);
      }
   
      /**
  @@ -133,139 +127,72 @@
       *  resources for the current application module.
      */
      public static MessageResources getMessageResources(ServletContext application) {
  -      return (MessageResources)application.getAttribute(Action.MESSAGES_KEY);
  +       return 
org.apache.struts.validator.Resources.getMessageResources(application);
      }
   
      /**
       * Retrieve <code>MessageResources</code> for the application module.
      */
      public static MessageResources getMessageResources(HttpServletRequest request) {
  -      return (MessageResources)request.getAttribute(Action.MESSAGES_KEY);
  +       return org.apache.struts.validator.Resources.getMessageResources(request);
      }
   
      /**
       * Get the <code>Locale</code> of the current user.
      */
      public static Locale getLocale(HttpServletRequest request) {
  -      Locale locale = null;
  -      try {
  -          locale = (Locale) request.getSession().getAttribute(Action.LOCALE_KEY);
  -      } catch (IllegalStateException e) {   // Invalidated session
  -          locale = null;
  -      }
  -      if (locale == null) {
  -         locale = defaultLocale;
  -      }
  -
  -      return locale;
  +       return org.apache.struts.validator.Resources.getLocale(request);
      }
   
      /**
       * Gets the <code>Locale</code> sensitive value based on the key passed in.
      */
      public static String getMessage(MessageResources messages, Locale locale, String 
key) {
  -      String message = null;
  -
  -      if (messages != null) {
  -         message = messages.getMessage(locale, key);
  -      }
  -      if (message == null) {
  -         message = "";
  -      }
  -
  -      return message;
  +       return org.apache.struts.validator.Resources.getMessage(messages,locale,key);
      }
   
      /**
       * Gets the <code>Locale</code> sensitive value based on the key passed in.
      */
      public static String getMessage(HttpServletRequest request, String key) {
  -      MessageResources messages = getMessageResources(request);
  -
  -      return getMessage(messages, getLocale(request), key);
  +       return org.apache.struts.validator.Resources.getMessage(request,key);
      }
   
      /**
       * Gets the locale sensitive message based on the <code>ValidatorAction</code> 
message and the
       * <code>Field</code>'s arg objects.
  +    *@deprecated  As of Struts 1.1b3, replaced by {@link 
org.apache.struts.validator.Resources#getMessage(MessageResources, Locale, 
ValidatorAction , Field)}
      */
      public static String getMessage(MessageResources messages, Locale locale,
                                      ValidatorAction va, Field field) {
  -
  -      String arg[] = getArgs(va.getName(), messages, locale, field);
  -      String msg = (field.getMsg(va.getName()) != null ? field.getMsg(va.getName()) 
: va.getMsg());
  -
  -      return messages.getMessage(locale, msg, arg[0], arg[1], arg[2], arg[3]);
  +       return 
org.apache.struts.validator.Resources.getMessage(messages,locale,va,field);
      }
   
      /**
       * Gets the <code>ActionError</code> based on the <code>ValidatorAction</code> 
message and the
       * <code>Field</code>'s arg objects.
  +    *@deprecated  As of Struts 1.1b3, replaced by {@link 
org.apache.struts.validator.Resources#getActionError(HttpServletRequest, 
ValidatorAction, Field)}
      */
      public static ActionError getActionError(HttpServletRequest request,
                                               ValidatorAction va, Field field) {
   
  -      String arg[] = getArgs(va.getName(), getMessageResources(request), 
getLocale(request), field);
  -      String msg = (field.getMsg(va.getName()) != null ? field.getMsg(va.getName()) 
: va.getMsg());
  -
  -      return new ActionError(msg, arg[0], arg[1], arg[2], arg[3]);
  +      return org.apache.struts.validator.Resources.getActionError(request,va,field);
      }
   
      /**
       * Gets the message arguments based on the current <code>ValidatorAction</code>
       * and <code>Field</code>.
  +    *@deprecated  As of Struts 1.1b3, replaced by {@link 
org.apache.struts.validator.Resources#getArgs(String,MessageResources,Locale,Field)}
      */
      public static String[] getArgs(String actionName, MessageResources messages,
                                     Locale locale, Field field) {
   
  -      Arg arg0 = field.getArg0(actionName);
  -      Arg arg1 = field.getArg1(actionName);
  -      Arg arg2 = field.getArg2(actionName);
  -      Arg arg3 = field.getArg3(actionName);
  -
  -      String sArg0 = null;
  -      String sArg1 = null;
  -      String sArg2 = null;
  -      String sArg3 = null;
  -
  -      if (arg0 != null) {
  -         if (arg0.getResource()) {
  -            sArg0 = getMessage(messages, locale, arg0.getKey());
  -         } else {
  -            sArg0 = arg0.getKey();
  -         }
  -      }
  -
  -      if (arg1 != null) {
  -         if (arg1.getResource()) {
  -            sArg1 = getMessage(messages, locale, arg1.getKey());
  -         } else {
  -            sArg1 = arg1.getKey();
  -         }
  -      }
  -
  -      if (arg2 != null) {
  -         if (arg2.getResource()) {
  -            sArg2 = getMessage(messages, locale, arg2.getKey());
  -         } else {
  -            sArg2 = arg2.getKey();
  -         }
  -      }
  -
  -      if (arg3 != null) {
  -         if (arg3.getResource()) {
  -            sArg3 = getMessage(messages, locale, arg3.getKey());
  -         } else {
  -            sArg3 = arg3.getKey();
  -         }
  -      }
  -
  -      return new String[] { sArg0, sArg1, sArg2, sArg3 };
  -
  +      return 
org.apache.struts.validator.Resources.getArgs(actionName,messages,locale,field);
      }
   
      /**
       * Initialize the <code>Validator</code> to perform validation.
  +    *@deprecated  As of Struts 1.1b3, replaced by {@link 
org.apache.struts.validator.Resources#initValidator(String,Object,ServletContext,HttpServletRequest,ActionErrors,int)}
       *
       * @param    key     The key that the validation rules are under
       *               (the form elements name attribute).
  @@ -276,21 +203,8 @@
                                            ServletContext application, 
HttpServletRequest request,
                                            ActionErrors errors, int page) {
   
  -      ValidatorResources resources = 
StrutsValidatorUtil.getValidatorResources(application,request);
  -      Locale locale = StrutsValidatorUtil.getLocale(request);
  -
  -      Validator validator = new Validator(resources, key);
  -      validator.setUseContextClassLoader(true);
  -
  -      validator.setPage(page);
  -
  -      validator.addResource(SERVLET_CONTEXT_KEY, application);
  -      validator.addResource(HTTP_SERVLET_REQUEST_KEY, request);
  -      validator.addResource(Validator.LOCALE_KEY, locale);
  -      validator.addResource(ACTION_ERRORS_KEY, errors);
  -      validator.addResource(Validator.BEAN_KEY, bean);
  +       return 
org.apache.struts.validator.Resources.initValidator(key,bean,application,request,errors,page);
   
  -      return validator;
      }
   
   }
  
  
  
  1.7       +5 -6      
jakarta-struts/src/share/org/apache/struts/validator/DynaValidatorActionForm.java
  
  Index: DynaValidatorActionForm.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-struts/src/share/org/apache/struts/validator/DynaValidatorActionForm.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- DynaValidatorActionForm.java      16 Oct 2002 22:41:42 -0000      1.6
  +++ DynaValidatorActionForm.java      18 Oct 2002 01:35:02 -0000      1.7
  @@ -72,7 +72,6 @@
   import org.apache.commons.validator.ValidatorException;
   import org.apache.struts.action.ActionErrors;
   import org.apache.struts.action.ActionMapping;
  -import org.apache.struts.util.StrutsValidatorUtil;
   
   
   /**
  @@ -114,7 +113,7 @@
           ServletContext application = getServlet().getServletContext();
           ActionErrors errors = new ActionErrors();
   
  -        Validator validator = StrutsValidatorUtil.initValidator(mapping.getPath(),
  +        Validator validator = Resources.initValidator(mapping.getPath(),
                                this,
                                application, request,
                                errors, page);
  
  
  
  1.6       +1 -1      
jakarta-struts/src/share/org/apache/struts/validator/DynaValidatorForm.java
  
  Index: DynaValidatorForm.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-struts/src/share/org/apache/struts/validator/DynaValidatorForm.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- DynaValidatorForm.java    16 Oct 2002 22:41:42 -0000      1.5
  +++ DynaValidatorForm.java    18 Oct 2002 01:35:02 -0000      1.6
  @@ -1 +1 @@
  -/*
 * $Header$
 * $Revision$
 * $Date$
 *
 * 
====================================================================
 *
 * The Apache 
Software License, Version 1.1
 *
 * Copyright (c) 1999 The Apache Software Foundation. 
 All rights
 * reserved.
*
 * Redistribution and use in source and binary forms, with 
or without
 * modification, are permitted provided that the following conditions
 * 
are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    
notice, this list of conditions and the following disclaimer.
 *
 * 2. Redistributions 
in binary form must reproduce the above copyright
 *    notice, this list of 
conditions and the following disclaimer in
 *    the documentation and/or other 
materials provided with the
 *    distribution.
 *
 * 3. The end-user documentation 
included with the redistribution, if
 *    any, must include the following 
acknowlegement:
 *       "This product includes software developed by the
 *        
Apache Software Foundation (http://www.apache.org/)."
 *    Alternately, this 
acknowlegement may appear in the software itself,
 *    if and wherever such 
third-party acknowlegements normally appear.
 *
 * 4. The names "The Jakarta Project", 
"Struts", and "Apache Software
 *    Foundation" must not be used to endorse or 
promote products derived
 *    from this software without prior written permission. 
For written
 *    permission, please contact [EMAIL PROTECTED]
 *
 * 5. Products 
derived from this software may not be called "Apache"
 *    nor may "Apache" appear in 
their names without prior written
 *    permission of the Apache Group.
 *
 * THIS 
SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 * WARRANTIES, INCLUDING, 
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A 
PARTICULAR PURPOSE ARE
 * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE 
FOUNDATION OR
 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * 
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, 
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
 * USE, DATA, OR PROFITS; OR 
BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN 
CONTRACT, STRICT LIABILITY,
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 
ANY WAY OUT
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * 
SUCH DAMAGE.
 * ====================================================================
 
*
 * This software consists of voluntary contributions made by many
 * individuals on 
behalf of the Apache Software Foundation.  For more
 * information on the Apache 
Software Foundation, please see
 * <http://www.apache.org/>.
 */

package 
org.apache.struts.validator;

import java.io.Serializable;
import java.util.Map;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.beanutils.DynaBean;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import 
org.apache.commons.validator.Validator;
import 
org.apache.commons.validator.ValidatorException;
import 
org.apache.commons.validator.ValidatorResults;
import 
org.apache.struts.action.ActionErrors;
import org.apache.struts.action.DynaActionForm;
import org.apache.struts.action.ActionMapping;
import 
org.apache.struts.util.StrutsValidatorUtil;

/**
 * <p>This class extends 
<strong>DynaActionForm</strong> and provides
 * basic field validation based on an XML 
file.  The key passed into the
 * validator is the action element's 'name' attribute 
from the
 * struts-config.xml which should match the form element's name attribute
 * 
in the validation.xml.</p>
 *
 * <ul><li>See <code>ValidatorPlugin</code> definition 
in struts-config.xml
 * for validation rules.</li></ul>
 *
 * @author David 
Winterfeldt
 * @version $Revision$ $Date$
 * @since Struts 1.1
 * @see 
org.apache.struts.action.ActionForm
 */

public class DynaValidatorForm extends 
DynaActionForm implements DynaBean, Serializable {

    /**
     * Commons Logging 
instance.
     */
    private static Log log = 
LogFactory.getLog(DynaValidatorForm.class);

   /**
     * The results returned from 
the validation performed
     * by the <code>Validator</code>.
     */
    protected 
ValidatorResults validatorResults = null;

   /**
     * Used to indicate the current 
page of a multi-page form.
     */
    protected int page = 0;

   /**
     * Gets 
page.
    * @return page number.
     */
    public int getPage() {
        return 
page;
    }

   /**
     * Sets page.
    * @param page page number
     */
    public 
void setPage(int page) {
        this.page = page;
    }

   /**
     * Validate the 
properties that have been set from this HTTP request,
     * and return an 
<code>ActionErrors</code> object that encapsulates any
     * validation errors that 
have been found.  If no errors are found, return
     * <code>null</code> or an 
<code>ActionErrors</code> object with no
     * recorded error messages.
     *
     * 
@param mapping The mapping used to select this instance
     * @param request The 
servlet request we are processing
    * @return  <code>ActionErrors</code> object that 
encapsulates any  validation errors
     */
    public ActionErrors 
validate(ActionMapping mapping,
                                 HttpServletRequest 
request) {

       ServletContext application = getServlet().getServletContext();
     
   ActionErrors errors = new ActionErrors();

       Validator validator = 
StrutsValidatorUtil.initValidator(mapping.getAttribute(),
                             
this,
                             application, request,
                             
errors, page);

       try {
            validatorResults = validator.validate();
     
   } catch (ValidatorException e) {
            log.error(e.getMessage(), e);
        
}

       return errors;
    }

   /**
     * Convenience method that call the 
comparable servlet log method and writes
     * an explanatory message and a stack 
trace for a given Throwable exception to the
     * servlet log file.
     *
     * 
@param   message     String that describes the error or exception
     */
    
protected void log(String message) {
        if (getServlet().getDebug() >= 1) {
      
      getServlet().log(message);
        }
    }

   /**
     * Convenience method 
that call the comparable servlet log method and writes
     * an explanatory message 
and a stack trace for a given Throwable exception to the
     * servlet log file.
     
*
     * @param   message     String that describes the error or exception
     * 
@param   throwable   Throwable error or exception
     */
    protected void 
log(String message, Throwable throwable) {
        if (getServlet().getDebug() >= 1) {
            getServlet().log(message, throwable);
        }
    }

   /**
     * Reset 
all properties to their default values.
     *
     * @param mapping The mapping used 
to select this instance
     * @param request The servlet request we are processing
   
  */
    public void reset(ActionMapping mapping, HttpServletRequest request) {
       
 super.reset(mapping, request);
        page = 0;
        validatorResults = null;
    
}

   /**
     * Get results of the validation performed by the
     * 
<code>Validator</code>.
    * @return validator results as ValidatorResults object
    
 */
    public ValidatorResults getValidatorResults() {
        return 
validatorResults;
    }

   /**
     * Set results of the validation performed by the
 
    * <code>Validator</code>.
    * @param validatorResults  Set results of the 
validation performed
     */
    public void setValidatorResults(ValidatorResults 
validatorResults) {
        this.validatorResults = validatorResults;
    }

   /**
   
  * Returns a <code>Map</code> of values returned
     * from any validation that 
returns a value other than
     * <code>null</code> or <code>Boolean</code> with the
  
   * key the full property path of the field.
    * @return Returns a <code>Map</code> 
of values, otherwise returns null if no results.
     */
    public Map 
getResultValueMap() {
        return (validatorResults != null ? 
validatorResults.getResultValueMap() : null);
    }

}

  \ No newline at end of file
  +/*
 * $Header$
 * $Revision$
 * $Date$
 *
 * 
====================================================================
 *
 * The Apache 
Software License, Version 1.1
 *
 * Copyright (c) 1999 The Apache Software Foundation. 
 All rights
 * reserved.
*
 * Redistribution and use in source and binary forms, with 
or without
 * modification, are permitted provided that the following conditions
 * 
are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    
notice, this list of conditions and the following disclaimer.
 *
 * 2. Redistributions 
in binary form must reproduce the above copyright
 *    notice, this list of 
conditions and the following disclaimer in
 *    the documentation and/or other 
materials provided with the
 *    distribution.
 *
 * 3. The end-user documentation 
included with the redistribution, if
 *    any, must include the following 
acknowlegement:
 *       "This product includes software developed by the
 *        
Apache Software Foundation (http://www.apache.org/)."
 *    Alternately, this 
acknowlegement may appear in the software itself,
 *    if and wherever such 
third-party acknowlegements normally appear.
 *
 * 4. The names "The Jakarta Project", 
"Struts", and "Apache Software
 *    Foundation" must not be used to endorse or 
promote products derived
 *    from this software without prior written permission. 
For written
 *    permission, please contact [EMAIL PROTECTED]
 *
 * 5. Products 
derived from this software may not be called "Apache"
 *    nor may "Apache" appear in 
their names without prior written
 *    permission of the Apache Group.
 *
 * THIS 
SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 * WARRANTIES, INCLUDING, 
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A 
PARTICULAR PURPOSE ARE
 * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE 
FOUNDATION OR
 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * 
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, 
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
 * USE, DATA, OR PROFITS; OR 
BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN 
CONTRACT, STRICT LIABILITY,
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 
ANY WAY OUT
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * 
SUCH DAMAGE.
 * ====================================================================
 
*
 * This software consists of voluntary contributions made by many
 * individuals on 
behalf of the Apache Software Foundation.  For more
 * information on the Apache 
Software Foundation, please see
 * <http://www.apache.org/>.
 */

package 
org.apache.struts.validator;

import java.io.Serializable;
import java.util.Map;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.beanutils.DynaBean;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import 
org.apache.commons.validator.Validator;
import 
org.apache.commons.validator.ValidatorException;
import 
org.apache.commons.validator.ValidatorResults;
import 
org.apache.struts.action.ActionErrors;
import org.apache.struts.action.DynaActionForm;
import org.apache.struts.action.ActionMapping;

/**
 * <p>This class extends 
<strong>DynaActionForm</strong> and provides
 * basic field validation based on an XML 
file.  The key passed into the
 * validator is the action element's 'name' attribute 
from the
 * struts-config.xml which should match the form element's name attribute
 * 
in the validation.xml.</p>
 *
 * <ul><li>See <code>ValidatorPlugin</code> definition 
in struts-config.xml
 * for validation rules.</li></ul>
 *
 * @author David 
Winterfeldt
 * @version $Revision$ $Date$
 * @since Struts 1.1
 * @see 
org.apache.struts.action.ActionForm
 */

public class DynaValidatorForm extends 
DynaActionForm implements DynaBean, Serializable {

    /**
     * Commons Logging 
instance.
     */
    private static Log log = 
LogFactory.getLog(DynaValidatorForm.class);

   /**
     * The results returned from 
the validation performed
     * by the <code>Validator</code>.
     */
    protected 
ValidatorResults validatorResults = null;

   /**
     * Used to indicate the current 
page of a multi-page form.
     */
    protected int page = 0;

   /**
     * Gets 
page.
    * @return page number.
     */
    public int getPage() {
        return 
page;
    }

   /**
     * Sets page.
    * @param page page number
     */
    public 
void setPage(int page) {
        this.page = page;
    }

   /**
     * Validate the 
properties that have been set from this HTTP request,
     * and return an 
<code>ActionErrors</code> object that encapsulates any
     * validation errors that 
have been found.  If no errors are found, return
     * <code>null</code> or an 
<code>ActionErrors</code> object with no
     * recorded error messages.
     *
     * 
@param mapping The mapping used to select this instance
     * @param request The 
servlet request we are processing
    * @return  <code>ActionErrors</code> object that 
encapsulates any  validation errors
     */
    public ActionErrors 
validate(ActionMapping mapping,
                                 HttpServletRequest 
request) {

       ServletContext application = getServlet().getServletContext();
     
   ActionErrors errors = new ActionErrors();

       Validator validator = 
Resources.initValidator(mapping.getAttribute(),
                             this,
    
                         application, request,
                             errors, 
page);

       try {
            validatorResults = validator.validate();
        } 
catch (ValidatorException e) {
            log.error(e.getMessage(), e);
        }

   
    return errors;
    }

   /**
     * Convenience method that call the comparable 
servlet log method and writes
     * an explanatory message and a stack trace for a 
given Throwable exception to the
     * servlet log file.
     *
     * @param   
message     String that describes the error or exception
     */
    protected void 
log(String message) {
        if (getServlet().getDebug() >= 1) {
            
getServlet().log(message);
        }
    }

   /**
     * Convenience method that call 
the comparable servlet log method and writes
     * an explanatory message and a stack 
trace for a given Throwable exception to the
     * servlet log file.
     *
     * 
@param   message     String that describes the error or exception
     * @param   
throwable   Throwable error or exception
     */
    protected void log(String 
message, Throwable throwable) {
        if (getServlet().getDebug() >= 1) {
           
 getServlet().log(message, throwable);
        }
    }

   /**
     * Reset all 
properties to their default values.
     *
     * @param mapping The mapping used to 
select this instance
     * @param request The servlet request we are processing
     
*/
    public void reset(ActionMapping mapping, HttpServletRequest request) {
        
super.reset(mapping, request);
        page = 0;
        validatorResults = null;
    
}

   /**
     * Get results of the validation performed by the
     * 
<code>Validator</code>.
    * @return validator results as ValidatorResults object
    
 */
    public ValidatorResults getValidatorResults() {
        return 
validatorResults;
    }

   /**
     * Set results of the validation performed by the
 
    * <code>Validator</code>.
    * @param validatorResults  Set results of the 
validation performed
     */
    public void setValidatorResults(ValidatorResults 
validatorResults) {
        this.validatorResults = validatorResults;
    }

   /**
   
  * Returns a <code>Map</code> of values returned
     * from any validation that 
returns a value other than
     * <code>null</code> or <code>Boolean</code> with the
  
   * key the full property path of the field.
    * @return Returns a <code>Map</code> 
of values, otherwise returns null if no results.
     */
    public Map 
getResultValueMap() {
        return (validatorResults != null ? 
validatorResults.getResultValueMap() : null);
    }

}

  \ No newline at end of file
  
  
  
  1.6       +5 -6      
jakarta-struts/src/share/org/apache/struts/validator/ValidatorActionForm.java
  
  Index: ValidatorActionForm.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-struts/src/share/org/apache/struts/validator/ValidatorActionForm.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ValidatorActionForm.java  16 Oct 2002 22:41:42 -0000      1.5
  +++ ValidatorActionForm.java  18 Oct 2002 01:35:02 -0000      1.6
  @@ -71,7 +71,6 @@
   import org.apache.commons.validator.ValidatorException;
   import org.apache.struts.action.ActionErrors;
   import org.apache.struts.action.ActionMapping;
  -import org.apache.struts.util.StrutsValidatorUtil;
   
   
   /**
  @@ -113,7 +112,7 @@
           ServletContext application = getServlet().getServletContext();
           ActionErrors errors = new ActionErrors();
   
  -        Validator validator = StrutsValidatorUtil.initValidator(mapping.getPath(),
  +        Validator validator = Resources.initValidator(mapping.getPath(),
                                this,
                                application, request,
                                errors, page);
  
  
  
  1.7       +1 -1      
jakarta-struts/src/share/org/apache/struts/validator/ValidatorForm.java
  
  Index: ValidatorForm.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-struts/src/share/org/apache/struts/validator/ValidatorForm.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- ValidatorForm.java        16 Oct 2002 22:41:42 -0000      1.6
  +++ ValidatorForm.java        18 Oct 2002 01:35:02 -0000      1.7
  @@ -1 +1 @@
  -/*
 * $Header$
 * $Revision$
 * $Date$
 *
 * 
====================================================================
 *
 * The Apache 
Software License, Version 1.1
 *
 * Copyright (c) 1999 The Apache Software Foundation. 
 All rights
 * reserved.
 *
 * Redistribution and use in source and binary forms, with 
or without
 * modification, are permitted provided that the following conditions
* are 
met:
*
 * 1. Redistributions of source code must retain the above copyright
 *    
notice, this list of conditions and the following disclaimer.
 *
 * 2. Redistributions 
in binary form must reproduce the above copyright
 *    notice, this list of 
conditions and the following disclaimer in
 *    the documentation and/or other 
materials provided with the
 *    distribution.
 *
 * 3. The end-user documentation 
included with the redistribution, if
 *    any, must include the following 
acknowlegement:
 *       "This product includes software developed by the
 *        
Apache Software Foundation (http://www.apache.org/)."
 *    Alternately, this 
acknowlegement may appear in the software itself,
 *    if and wherever such 
third-party acknowlegements normally appear.
 *
 * 4. The names "The Jakarta Project", 
"Struts", and "Apache Software
 *    Foundation" must not be used to endorse or 
promote products derived
 *    from this software without prior written permission. 
For written
 *    permission, please contact [EMAIL PROTECTED]
 *
 * 5. Products 
derived from this software may not be called "Apache"
 *    nor may "Apache" appear in 
their names without prior written
 *    permission of the Apache Group.
 *
 * THIS 
SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 * WARRANTIES, INCLUDING, 
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A 
PARTICULAR PURPOSE ARE
 * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE 
FOUNDATION OR
 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * 
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, 
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
 * USE, DATA, OR PROFITS; OR 
BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN 
CONTRACT, STRICT LIABILITY,
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 
ANY WAY OUT
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * 
SUCH DAMAGE.
 * ====================================================================
 
*
 * This software consists of voluntary contributions made by many
 * individuals on 
behalf of the Apache Software Foundation.  For more
 * information on the Apache 
Software Foundation, please see
 * <http://www.apache.org/>.
 */

package 
org.apache.struts.validator;

import java.io.Serializable;

import java.util.Map;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.commons.validator.Validator;
import 
org.apache.commons.validator.ValidatorException;
import 
org.apache.commons.validator.ValidatorResults;
import 
org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import 
org.apache.struts.util.StrutsValidatorUtil;

/**
 * <p>This class extends 
<strong>ActionForm</strong> and provides
 * basic field validation based on an XML 
file.  The key passed into the
 * validator is the action element's 'name' attribute 
from the
 * struts-config.xml which should match the form element's name attribute
 * 
in the validation.xml.</p>
 *
 * <ul><li>See <code>ValidatorPlugin</code> definition 
in struts-config.xml
 * for validation rules.</li></ul>
 *
 * @author David 
Winterfeldt
 * @version $Revision$ $Date$
 * @see org.apache.struts.action.ActionForm
 
* @since Struts 1.1
 */

public class ValidatorForm extends ActionForm implements 
Serializable {

    /**
     * Commons Logging instance.
     */
    private static 
Log log = LogFactory.getLog(ValidatorForm.class);

    /**
     * The results returned 
from the validation performed
     * by the <code>Validator</code>.
     */
    
protected ValidatorResults validatorResults = null;

    /**
     * Used to indicate 
the current page of a multi-page form.
     */
    protected int page = 0;

    /**
   
  * Gets page.
     * @return page number
     */
    public int getPage() {
        
return page;
    }

    /**
     * Sets page.
     * @param page page number
     */
  
  public void setPage(int page) {
        this.page = page;
    }

    /**
     * 
Validate the properties that have been set from this HTTP request,
     * and return 
an <code>ActionErrors</code> object that encapsulates any
     * validation errors 
that have been found.  If no errors are found, return
     * <code>null</code> or an 
<code>ActionErrors</code> object with no
     * recorded error messages.
     *
     * 
@param mapping The mapping used to select this instance
     * @param request The 
servlet request we are processing
     * @return  <code>ActionErrors</code> object 
that encapsulates any  validation errors

     */
    public ActionErrors 
validate(ActionMapping mapping,
                                 HttpServletRequest 
request) {

        ServletContext application = getServlet().getServletContext();
    
    ActionErrors errors = new ActionErrors();

        Validator validator = 
StrutsValidatorUtil.initValidator(mapping.getAttribute(),
                             
this,
                             application, request,
                             
errors, page);

        try {
            validatorResults = validator.validate();
    
    } catch (ValidatorException e) {
            log.error(e.getMessage(), e);
        
}

        return errors;
    }

    /**
     * Convenience method that call the 
comparable servlet log method and writes
     * an explanatory message and a stack 
trace for a given Throwable exception to the
     * servlet log file.
     *
     * 
@param   message     String that describes the error or exception
     */
    
protected void log(String message) {
        if (getServlet().getDebug() >= 1) {
      
      getServlet().log(message);
        }
    }

    /**
     * Convenience method 
that call the comparable servlet log method and writes
     * an explanatory message 
and a stack trace for a given Throwable exception to the
     * servlet log file.
     
*
     * @param   message     String that describes the error or exception
     * 
@param   throwable   Throwable error or exception
     */
    protected void 
log(String message, Throwable throwable) {
        if (getServlet().getDebug() >= 1) {
            getServlet().log(message, throwable);
        }
    }

    /**
     * 
Reset all properties to their default values.
     *
     * @param mapping The mapping 
used to select this instance
     * @param request The servlet request we are 
processing
     */
    public void reset(ActionMapping mapping, HttpServletRequest 
request) {
        super.reset(mapping, request);
        page = 0;
        
validatorResults = null;
    }

    /**
     * Get results of the validation performed 
by the
     * <code>Validator</code>.
     * @return results of the validation
     */
    public ValidatorResults getValidatorResults() {
        return validatorResults;
  
  }

    /**
     * Set results of the validation performed by the
     * 
<code>Validator</code>.
     * @param validatorResults results of validation
     */
  
  public void setValidatorResults(ValidatorResults validatorResults) {
        
this.validatorResults = validatorResults;
    }

    /**
     * Returns a 
<code>Map</code> of values returned
     * from any validation that returns a value 
other than
     * <code>null</code> or <code>Boolean</code> with the
     * key the 
full property path of the field.
     * @return  <code>Map</code> of non-null values
  
   */
    public Map getResultValueMap() {
        return (validatorResults != null ? 
validatorResults.getResultValueMap() : null);
    }
}
  \ No newline at end of file
  +/*
 * $Header$
 * $Revision$
 * $Date$
 *
 * 
====================================================================
 *
 * The Apache 
Software License, Version 1.1
 *
 * Copyright (c) 1999 The Apache Software Foundation. 
 All rights
 * reserved.
 *
 * Redistribution and use in source and binary forms, with 
or without
 * modification, are permitted provided that the following conditions
* are 
met:
*
 * 1. Redistributions of source code must retain the above copyright
 *    
notice, this list of conditions and the following disclaimer.
 *
 * 2. Redistributions 
in binary form must reproduce the above copyright
 *    notice, this list of 
conditions and the following disclaimer in
 *    the documentation and/or other 
materials provided with the
 *    distribution.
 *
 * 3. The end-user documentation 
included with the redistribution, if
 *    any, must include the following 
acknowlegement:
 *       "This product includes software developed by the
 *        
Apache Software Foundation (http://www.apache.org/)."
 *    Alternately, this 
acknowlegement may appear in the software itself,
 *    if and wherever such 
third-party acknowlegements normally appear.
 *
 * 4. The names "The Jakarta Project", 
"Struts", and "Apache Software
 *    Foundation" must not be used to endorse or 
promote products derived
 *    from this software without prior written permission. 
For written
 *    permission, please contact [EMAIL PROTECTED]
 *
 * 5. Products 
derived from this software may not be called "Apache"
 *    nor may "Apache" appear in 
their names without prior written
 *    permission of the Apache Group.
 *
 * THIS 
SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 * WARRANTIES, INCLUDING, 
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A 
PARTICULAR PURPOSE ARE
 * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE 
FOUNDATION OR
 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * 
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, 
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
 * USE, DATA, OR PROFITS; OR 
BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN 
CONTRACT, STRICT LIABILITY,
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 
ANY WAY OUT
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * 
SUCH DAMAGE.
 * ====================================================================
 
*
 * This software consists of voluntary contributions made by many
 * individuals on 
behalf of the Apache Software Foundation.  For more
 * information on the Apache 
Software Foundation, please see
 * <http://www.apache.org/>.
 */

package 
org.apache.struts.validator;

import java.io.Serializable;

import java.util.Map;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.commons.validator.Validator;
import 
org.apache.commons.validator.ValidatorException;
import 
org.apache.commons.validator.ValidatorResults;
import 
org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;

/**
 * <p>This class extends 
<strong>ActionForm</strong> and provides
 * basic field validation based on an XML 
file.  The key passed into the
 * validator is the action element's 'name' attribute 
from the
 * struts-config.xml which should match the form element's name attribute
 * 
in the validation.xml.</p>
 *
 * <ul><li>See <code>ValidatorPlugin</code> definition 
in struts-config.xml
 * for validation rules.</li></ul>
 *
 * @author David 
Winterfeldt
 * @version $Revision$ $Date$
 * @see org.apache.struts.action.ActionForm
 
* @since Struts 1.1
 */

public class ValidatorForm extends ActionForm implements 
Serializable {

    /**
     * Commons Logging instance.
     */
    private static 
Log log = LogFactory.getLog(ValidatorForm.class);

    /**
     * The results returned 
from the validation performed
     * by the <code>Validator</code>.
     */
    
protected ValidatorResults validatorResults = null;

    /**
     * Used to indicate 
the current page of a multi-page form.
     */
    protected int page = 0;

    /**
   
  * Gets page.
     * @return page number
     */
    public int getPage() {
        
return page;
    }

    /**
     * Sets page.
     * @param page page number
     */
  
  public void setPage(int page) {
        this.page = page;
    }

    /**
     * 
Validate the properties that have been set from this HTTP request,
     * and return 
an <code>ActionErrors</code> object that encapsulates any
     * validation errors 
that have been found.  If no errors are found, return
     * <code>null</code> or an 
<code>ActionErrors</code> object with no
     * recorded error messages.
     *
     * 
@param mapping The mapping used to select this instance
     * @param request The 
servlet request we are processing
     * @return  <code>ActionErrors</code> object 
that encapsulates any  validation errors

     */
    public ActionErrors 
validate(ActionMapping mapping,
                                 HttpServletRequest 
request) {

        ServletContext application = getServlet().getServletContext();
    
    ActionErrors errors = new ActionErrors();

        Validator validator = 
Resources.initValidator(mapping.getAttribute(),
                             this,
    
                         application, request,
                             errors, 
page);

        try {
            validatorResults = validator.validate();
        } 
catch (ValidatorException e) {
            log.error(e.getMessage(), e);
        }

   
     return errors;
    }

    /**
     * Convenience method that call the comparable 
servlet log method and writes
     * an explanatory message and a stack trace for a 
given Throwable exception to the
     * servlet log file.
     *
     * @param   
message     String that describes the error or exception
     */
    protected void 
log(String message) {
        if (getServlet().getDebug() >= 1) {
            
getServlet().log(message);
        }
    }

    /**
     * Convenience method that 
call the comparable servlet log method and writes
     * an explanatory message and a 
stack trace for a given Throwable exception to the
     * servlet log file.
     *
    
 * @param   message     String that describes the error or exception
     * @param   
throwable   Throwable error or exception
     */
    protected void log(String 
message, Throwable throwable) {
        if (getServlet().getDebug() >= 1) {
           
 getServlet().log(message, throwable);
        }
    }

    /**
     * Reset all 
properties to their default values.
     *
     * @param mapping The mapping used to 
select this instance
     * @param request The servlet request we are processing
     
*/
    public void reset(ActionMapping mapping, HttpServletRequest request) {
        
super.reset(mapping, request);
        page = 0;
        validatorResults = null;
    
}

    /**
     * Get results of the validation performed by the
     * 
<code>Validator</code>.
     * @return results of the validation
     */
    public 
ValidatorResults getValidatorResults() {
        return validatorResults;
    }

    
/**
     * Set results of the validation performed by the
     * 
<code>Validator</code>.
     * @param validatorResults results of validation
     */
  
  public void setValidatorResults(ValidatorResults validatorResults) {
        
this.validatorResults = validatorResults;
    }

    /**
     * Returns a 
<code>Map</code> of values returned
     * from any validation that returns a value 
other than
     * <code>null</code> or <code>Boolean</code> with the
     * key the 
full property path of the field.
     * @return  <code>Map</code> of non-null values
  
   */
    public Map getResultValueMap() {
        return (validatorResults != null ? 
validatorResults.getResultValueMap() : null);
    }
}
  \ No newline at end of file
  
  
  

--
To unsubscribe, e-mail:   <mailto:struts-dev-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:struts-dev-help@;jakarta.apache.org>

Reply via email to