org.nuiton.validator.xwork2.field
Class NuitonFieldExpressionValidator

java.lang.Object
  extended by com.opensymphony.xwork2.validator.validators.ValidatorSupport
      extended by com.opensymphony.xwork2.validator.validators.FieldValidatorSupport
          extended by com.opensymphony.xwork2.validator.validators.FieldExpressionValidator
              extended by org.nuiton.validator.xwork2.field.NuitonFieldExpressionValidator
All Implemented Interfaces:
com.opensymphony.xwork2.validator.FieldValidator, com.opensymphony.xwork2.validator.ShortCircuitableValidator, com.opensymphony.xwork2.validator.Validator
Direct Known Subclasses:
CollectionFieldExpressionValidator, FieldExpressionWithParamsValidator

public class NuitonFieldExpressionValidator
extends com.opensymphony.xwork2.validator.validators.FieldExpressionValidator

Nuiton default field validator.

This validator offers a skip property that can be used to skip or not the validator, this property is a OGNL expression.

To use this new field validator support, just now implements the method validateWhenNotSkip(Object). This method will be invoked only if the skip parameter is evaluated to false.

Since:
2.3
Author:
tchemit

Field Summary
protected  String skip
          extra parameter at the very beginning of the validate(Object) method to be able to skip (or not) the validator execution.
 
Fields inherited from class com.opensymphony.xwork2.validator.validators.ValidatorSupport
defaultMessage, log, messageKey
 
Constructor Summary
NuitonFieldExpressionValidator()
           
 
Method Summary
protected  boolean evaluateSkipParameter(Object object)
          Evaluate the skip parameter value against the object to validate.
 void setSkip(String skip)
          Sets the value of the skip parameter.
 void validate(Object object)
           
protected  void validateWhenNotSkip(Object object)
          Method to be invoked when skip parameter was not evaludated to true.
 
Methods inherited from class com.opensymphony.xwork2.validator.validators.FieldExpressionValidator
getExpression, setExpression
 
Methods inherited from class com.opensymphony.xwork2.validator.validators.FieldValidatorSupport
getFieldName, getValidatorType, setFieldName, setValidatorType
 
Methods inherited from class com.opensymphony.xwork2.validator.validators.ValidatorSupport
addActionError, addFieldError, conditionalParse, getDefaultMessage, getFieldValue, getMessage, getMessageKey, getMessageParameters, getParse, getValidatorContext, isShortCircuit, setDefaultMessage, setMessageKey, setMessageParameters, setParse, setShortCircuit, setValidatorContext, setValueStack
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.opensymphony.xwork2.validator.Validator
getDefaultMessage, getMessage, getMessageKey, getMessageParameters, getValidatorContext, setDefaultMessage, setMessageKey, setMessageParameters, setValidatorContext, setValueStack
 

Field Detail

skip

protected String skip
extra parameter at the very beginning of the validate(Object) method to be able to skip (or not) the validator execution.

by default the value is false : it seems fair to want to validate if the validator is used :D...

Constructor Detail

NuitonFieldExpressionValidator

public NuitonFieldExpressionValidator()
Method Detail

setSkip

public void setSkip(String skip)
Sets the value of the skip parameter.

Parameters:
skip - the new value of the skip parameter

validateWhenNotSkip

protected void validateWhenNotSkip(Object object)
                            throws com.opensymphony.xwork2.validator.ValidationException
Method to be invoked when skip parameter was not evaludated to true.

Parameters:
object - the object to be validated.
Throws:
com.opensymphony.xwork2.validator.ValidationException - is thrown if there is validation error(s).

validate

public void validate(Object object)
              throws com.opensymphony.xwork2.validator.ValidationException
Specified by:
validate in interface com.opensymphony.xwork2.validator.Validator
Overrides:
validate in class com.opensymphony.xwork2.validator.validators.FieldExpressionValidator
Throws:
com.opensymphony.xwork2.validator.ValidationException

evaluateSkipParameter

protected boolean evaluateSkipParameter(Object object)
                                 throws com.opensymphony.xwork2.validator.ValidationException
Evaluate the skip parameter value against the object to validate.

This parameter can be an OGNL expression.

Parameters:
object - the object to validate
Returns:
the evaluation of the skip parameter.
Throws:
com.opensymphony.xwork2.validator.ValidationException - if could not evaluate the parameter


Copyright © 2011-2012 CodeLutin. All Rights Reserved.