com.townleyenterprises.validator
Interface FormValidator

All Superinterfaces:
java.io.Serializable
All Known Implementing Classes:
BasicFormValidator

public interface FormValidator
extends java.io.Serializable

This interface defines the validation functionality of a form as a whole. Each form has three different levels of validation which is possible:

Based on previous projects, this kind of granularity is necessary to fully encapsulate all of the possible kinds of form validation done in the real world.

The default order of the validations will be the following unless explicitly changed (and documented) by implementing classes.

  1. All individual field values
  2. All field sets
  3. The entire form

Since:
3.0
Version:
$Id: FormValidator.java,v 1.3 2004/08/11 16:24:22 atownley Exp $
Author:
Andrew S. Townley

Method Summary
 void addFieldSetValidator(FieldSetValidator validator)
          This method is used to add a new field set validator
 void addFieldValidator(java.lang.String name, FieldValidator validator)
          This method is used to add a new validator for a specific field of the form.
 void addValidationListener(ValidationListener listener)
           
 boolean getAbortOnFailure()
          This method is used to determine the mode of the form validator.
 FieldSetValidator[] getFieldSetValidators()
          This method returns the currently configured field set validators as an array.
 FieldValidator[] getFieldValidators()
          This method returns the currently configured field validators as an array.
 ValidationListener[] getValidationListeners()
           
 void removeFieldSetValidator(FieldSetValidator validator)
          This method is used to remove a new field set validator
 void removeFieldValidator(FieldValidator validator)
          This method is used to remove a specific validator instance.
 void removeValidationListener(ValidationListener listener)
           
 void setAbortOnFailure(boolean val)
          This method is used to set the validation mode of the form.
 void validate(Form form)
          This method will perform the validation of the supplied form according to the standard order or an implementation-defined order as documented by the specific implementation.
 void validate(Form form, java.util.Locale locale)
          This method performs the same validation as the validate(com.townleyenterprises.validator.Form) method except for taking a specific locale rather than using the default.
 

Method Detail

getAbortOnFailure

public boolean getAbortOnFailure()
This method is used to determine the mode of the form validator. If it returns false, the validator will attempt to perform all of the registered validations once and notify the listeners of any failures. If it returns true, the validation operation will stop after the first validation failure.

Returns:
false if all fields will be validated; true if not

setAbortOnFailure

public void setAbortOnFailure(boolean val)
This method is used to set the validation mode of the form. Two modes are supported: the first will validate all of the fields on the form (the default), and the second will only validate until the first validation failure occurrs.

Parameters:
val - the value of the flag

validate

public void validate(Form form)
              throws java.lang.Exception
This method will perform the validation of the supplied form according to the standard order or an implementation-defined order as documented by the specific implementation.

Parameters:
form - the form to validate
Throws:
java.lang.Exception - if any of the validations fail

validate

public void validate(Form form,
                     java.util.Locale locale)
              throws java.lang.Exception
This method performs the same validation as the validate(com.townleyenterprises.validator.Form) method except for taking a specific locale rather than using the default.

Parameters:
form - the form to validate
locale - the specific locale to use
Throws:
java.lang.Exception - if any of the validations fail

addFieldValidator

public void addFieldValidator(java.lang.String name,
                              FieldValidator validator)
This method is used to add a new validator for a specific field of the form.

Parameters:
name - the field name
validator - the validator instance

removeFieldValidator

public void removeFieldValidator(FieldValidator validator)
This method is used to remove a specific validator instance.

Parameters:
validator - the validator to remove

addFieldSetValidator

public void addFieldSetValidator(FieldSetValidator validator)
This method is used to add a new field set validator

Parameters:
validator - the validator to add

removeFieldSetValidator

public void removeFieldSetValidator(FieldSetValidator validator)
This method is used to remove a new field set validator

Parameters:
validator - the validator to remove

getFieldValidators

public FieldValidator[] getFieldValidators()
This method returns the currently configured field validators as an array.


getFieldSetValidators

public FieldSetValidator[] getFieldSetValidators()
This method returns the currently configured field set validators as an array.


addValidationListener

public void addValidationListener(ValidationListener listener)

removeValidationListener

public void removeValidationListener(ValidationListener listener)

getValidationListeners

public ValidationListener[] getValidationListeners()


Copyright © 2002-2004, Andrew S. Townley and Townley Enterprises. All Rights Reserved.
This project is hosted on http://te-code.sourceforge.net.