com.opensymphony.xwork2.validator.validators
Class ConditionalVisitorFieldValidator

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.VisitorFieldValidator
              extended by com.opensymphony.xwork2.validator.validators.ConditionalVisitorFieldValidator
All Implemented Interfaces:
FieldValidator, ShortCircuitableValidator, Validator

public class ConditionalVisitorFieldValidator
extends VisitorFieldValidator

ConditionalVisitorFieldValidator <field name="colleaguePosition"> <field-validator type="fieldexpression" short-circuit="true"> reason == 'colleague' and colleaguePositionID == '_CHOOSE_' <message>You must choose a position where you worked with this person, or choose "Other..."</message> </field-validator> <field-validator type="conditionalvisitor"> reason == 'colleague' and colleaguePositionID == 'OTHER' <message/> </field-validator> </field>

Author:
Matt Raible

Nested Class Summary
 
Nested classes/interfaces inherited from class com.opensymphony.xwork2.validator.validators.VisitorFieldValidator
VisitorFieldValidator.AppendingValidatorContext
 
Field Summary
 
Fields inherited from class com.opensymphony.xwork2.validator.validators.ValidatorSupport
defaultMessage, log, messageKey
 
Constructor Summary
ConditionalVisitorFieldValidator()
           
 
Method Summary
 java.lang.String getExpression()
           
 void setExpression(java.lang.String expression)
           
 void validate(java.lang.Object object)
          If expression evaluates to true, invoke visitor validation.
 boolean validateExpression(java.lang.Object object)
          Validate the expression contained in the "expression" paramter.
 
Methods inherited from class com.opensymphony.xwork2.validator.validators.VisitorFieldValidator
getContext, isAppendPrefix, setActionValidatorManager, setAppendPrefix, setContext
 
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
 

Constructor Detail

ConditionalVisitorFieldValidator

public ConditionalVisitorFieldValidator()
Method Detail

setExpression

public void setExpression(java.lang.String expression)

getExpression

public java.lang.String getExpression()

validate

public void validate(java.lang.Object object)
              throws ValidationException
If expression evaluates to true, invoke visitor validation.

Specified by:
validate in interface Validator
Overrides:
validate in class VisitorFieldValidator
Parameters:
object - the object being validated
Throws:
ValidationException

validateExpression

public boolean validateExpression(java.lang.Object object)
                           throws ValidationException
Validate the expression contained in the "expression" paramter.

Parameters:
object - the object you're validating
Returns:
true if expression evaluates to true (implying a validation failure)
Throws:
ValidationException - if anything goes wrong


Copyright © 2000-2011 Apache Software Foundation. All Rights Reserved.