15.7. Accumulating error messages

It is now possible to accumulate error messages while validating a form in a dbForms interceptor class. This is useful in situations where many fields are validated and you wish to return several errors instead of just the first occurrence. In the validation process, when an error occurs, simply instantiate a new exception object and store it into a vector. Do not throw this exception! Once the validation process has completed, throw an instance of the MultipleValidationException class and pass the vector as an argument to its constructor. Note that this functionality is dependant on using the xmlError tag. (refer to the section: DbForms Custom Tag Library for more information on using the xmlError tag)

Example 15.4. accumlating error messages

    public int 
        preUpdate(HttpServletRequest req, FieldValues fieldValues, DbformsConfig conf, 
      Connection con)
        throws ValidationException{
      
            Vector 
        errors = new Vector();
            
             // Validate, if error    
            
        errors.add(new SQLException("English-001:param");
            
            
             // More validations, errors    
            
        errors.add(new SQLException("Franais-003:param,param");
      
      
            if(!errors.isEmpty) 
        throw new MultipleValidationException(errors);
      
      
        }