Save This Page
Home » commons-validator-1.3.1-src » org.apache.commons » validator » [javadoc | source]
org.apache.commons.validator
public class: ValidatorAction [javadoc | source]
java.lang.Object
   org.apache.commons.validator.ValidatorAction

All Implemented Interfaces:
    Serializable

Contains the information to dynamically create and run a validation method. This is the class representation of a pluggable validator that can be defined in an xml file with the <validator> element. Note: The validation method is assumed to be thread safe.
Method from org.apache.commons.validator.ValidatorAction Summary:
executeValidationMethod,   getClassname,   getDependencyList,   getDepends,   getJavascript,   getJsFunctionName,   getMethod,   getMethodParams,   getMsg,   getName,   init,   isDependency,   loadJavascriptFunction,   setClassname,   setDepends,   setJavascript,   setJsFunction,   setJsFunctionName,   setMethod,   setMethodParams,   setMsg,   setName,   toString
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.apache.commons.validator.ValidatorAction Detail:
 boolean executeValidationMethod(Field field,
    Map params,
    ValidatorResults results,
    int pos) throws ValidatorException 
    Dynamically runs the validation method for this validator and returns true if the data is valid.
 public String getClassname() 
    Gets the class of the validator action.
 public List getDependencyList() 
    Returns the dependent validator names as an unmodifiable List.
 public String getDepends() 
    Gets the dependencies of the validator action as a comma separated list of validator names.
 public String getJavascript() 
    Gets the Javascript equivalent of the java class and method associated with this action.
 public String getJsFunctionName() 
    Gets the Javascript function name. This is optional and can be used instead of validator action name for the name of the Javascript function/object.
 public String getMethod() 
    Gets the name of method being called for the validator action.
 public String getMethodParams() 
    Gets the method parameters for the method.
 public String getMsg() 
    Gets the message associated with the validator action.
 public String getName() 
    Gets the name of the validator action.
 protected  void init() 
    Initialize based on set.
 public boolean isDependency(String validatorName) 
    Checks whether or not the value passed in is in the depends field.
 protected synchronized  void loadJavascriptFunction() 
    Load the javascript function specified by the given path. For this implementation, the jsFunction property should contain a fully qualified package and script name, separated by periods, to be loaded from the class loader that created this instance. TODO if the path begins with a '/' the path will be intepreted as absolute, and remain unchanged. If this fails then it will attempt to treat the path as a file path. It is assumed the script ends with a '.js'.
 public  void setClassname(String classname) 
    Sets the class of the validator action.
 public  void setDepends(String depends) 
    Sets the dependencies of the validator action.
 public  void setJavascript(String javascript) 
    Sets the Javascript equivalent of the java class and method associated with this action.
 public  void setJsFunction(String jsFunction) 
    Sets the fully qualified class path of the Javascript function.

    This is optional and can be used instead of the setJavascript(). Attempting to call both setJsFunction and setJavascript will result in an IllegalStateException being thrown.

    If neither setJsFunction or setJavascript is set then validator will attempt to load the default javascript definition.

    Examples
    If in the validator.xml :
    #1:
    <validator name="tire"
    jsFunction="com.yourcompany.project.tireFuncion">
    Validator will attempt to load com.yourcompany.project.validateTireFunction.js from
    its class path.
    #2:
    <validator name="tire">
    Validator will use the name attribute to try and load
    org.apache.commons.validator.javascript.validateTire.js
    which is the default javascript definition.
    
 public  void setJsFunctionName(String jsFunctionName) 
    Sets the Javascript function name. This is optional and can be used instead of validator action name for the name of the Javascript function/object.
 public  void setMethod(String method) 
    Sets the name of method being called for the validator action.
 public  void setMethodParams(String methodParams) 
    Sets the method parameters for the method.
 public  void setMsg(String msg) 
    Sets the message associated with the validator action.
 public  void setName(String name) 
    Sets the name of the validator action.
 public String toString() 
    Returns a string representation of the object.