net.sf.springlayout.web.validator
Class AbstractValidationRule

java.lang.Object
  extended by net.sf.springlayout.web.validator.AbstractValidationRule
All Implemented Interfaces:
ValidationRule
Direct Known Subclasses:
DateValidator, DecimalNumberRangeValidator, DecimalValidator, EmailValidator, IntegerNumberRangeValidator, IntegerValidator, MaxLengthValidator, MaxValueValidator, MinLengthValidator, MinValueValidator

public abstract class AbstractValidationRule
extends java.lang.Object
implements ValidationRule

Abstract validation rule providing common functionality for concrete ValidationRule implementations

Author:
rob monie

Constructor Summary
AbstractValidationRule()
           
 
Method Summary
 void conditionallyValidate(javax.servlet.http.HttpServletRequest request, java.lang.Object obj, org.springframework.validation.Errors errors, java.lang.String fieldKey)
          Calls upon condition to determine whether the validation rule should applied or not then conditionally validates.
 Condition getCondition()
           
 java.lang.String getConditionalJavascript(OnPageFieldInstance fieldInstance, java.lang.Object command, java.lang.String formName)
          Retrieves a javascript representation of this validation rule which will be applied to each of the events supplied in eventNames.
 java.lang.Object getFieldValue(java.lang.Object obj, java.lang.String fieldKey)
          Gets a fields value based on its fieldKey / path.
abstract  java.lang.String getJavascript()
          Get the javascript used to validate this rule
 void setCondition(Condition condition)
          Set a condition to evaluate to determine whether to run this validation rule
protected abstract  void validate(javax.servlet.http.HttpServletRequest request, java.lang.Object obj, org.springframework.validation.Errors errors, java.lang.String fieldKey)
          Validate the object
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.sf.springlayout.web.validator.ValidationRule
isValid
 

Constructor Detail

AbstractValidationRule

public AbstractValidationRule()
Method Detail

getCondition

public Condition getCondition()
Returns:
the condition

setCondition

public void setCondition(Condition condition)
Set a condition to evaluate to determine whether to run this validation rule

Parameters:
condition - the condition to set

getFieldValue

public java.lang.Object getFieldValue(java.lang.Object obj,
                                      java.lang.String fieldKey)
Gets a fields value based on its fieldKey / path. Handles NullValueInNestedPathException

Parameters:
obj -
fieldKey -
Returns:

conditionallyValidate

public void conditionallyValidate(javax.servlet.http.HttpServletRequest request,
                                  java.lang.Object obj,
                                  org.springframework.validation.Errors errors,
                                  java.lang.String fieldKey)
Calls upon condition to determine whether the validation rule should applied or not then conditionally validates.

Specified by:
conditionallyValidate in interface ValidationRule
Parameters:
obj - the command object on which to validate
fieldKey - the fieldKey or path to the field in the object
request - the current HttpServletRequest
errors - the current errors for this request

validate

protected abstract void validate(javax.servlet.http.HttpServletRequest request,
                                 java.lang.Object obj,
                                 org.springframework.validation.Errors errors,
                                 java.lang.String fieldKey)
Validate the object

Parameters:
request -
obj -
errors -
fieldKey -

getConditionalJavascript

public java.lang.String getConditionalJavascript(OnPageFieldInstance fieldInstance,
                                                 java.lang.Object command,
                                                 java.lang.String formName)
Description copied from interface: ValidationRule
Retrieves a javascript representation of this validation rule which will be applied to each of the events supplied in eventNames. This function will be 'anded' together with other rules and so should always return boolean and have no semi-colon eg. A == B The context which surrounds this javascrit must contain the 'field' to execute this javascript upon.

Specified by:
getConditionalJavascript in interface ValidationRule
Returns:
String containing the conditional javascript registration for this validation rule against the event names supplied.

getJavascript

public abstract java.lang.String getJavascript()
Get the javascript used to validate this rule

Returns:


Copyright © 2005-2007 Spring Layout Team. All Rights Reserved.