org.springjutsu.validation.webflow
Class BaseWebflowValidator<T>

java.lang.Object
  extended by org.springjutsu.validation.webflow.BaseWebflowValidator<T>
Type Parameters:
T - Class which this validator validates
All Implemented Interfaces:
org.springframework.validation.Validator

public class BaseWebflowValidator<T>
extends Object
implements org.springframework.validation.Validator

An extensible / parameterizable base validator for use in Spring Webflow. Currently have to use this since there's no option in webflow to inject a custom @link{ValidationHelper} instance. So, users can extend and parameterize this instead, and register it as a validator bean, and bam nifty, it'll call validation. Chose this one because it supports the Errors object. The user can also perform validation outside of what's in XML by overriding the #doManualValidation method.

Author:
Clark Duplichien
See Also:
Validator, doManualValidation(String, String, Object, Errors)

Field Summary
protected  Class<T> entityClass
          The parameterization-specified class of which an instance will be validated by this validator.
 
Constructor Summary
BaseWebflowValidator()
          Default constructor.
 
Method Summary
protected  Class<T> calculateEntityClass()
          Calculates the class specified in the parameterization.
 void doManualValidation(String flowId, String stateId, Object target, org.springframework.validation.Errors errors)
          Overload doManualValidation if it is wished to perform validation in addition to what is specified in the rules.
 boolean supports(Class<?> clazz)
          Supports a class if this class was parameterized for it, and if the validation manager has rules for it.
 void validate(Object target, org.springframework.validation.Errors errors)
          Perform actual validation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

entityClass

protected Class<T> entityClass
The parameterization-specified class of which an instance will be validated by this validator.

Constructor Detail

BaseWebflowValidator

public BaseWebflowValidator()
Default constructor. Sets entity class from the parameterized argument.

Method Detail

calculateEntityClass

protected Class<T> calculateEntityClass()
Calculates the class specified in the parameterization.

Returns:
the parameterized class.

supports

public boolean supports(Class<?> clazz)
Supports a class if this class was parameterized for it, and if the validation manager has rules for it.

Specified by:
supports in interface org.springframework.validation.Validator
Parameters:
clazz - The class to check support for
Returns:
true if supported.

validate

public void validate(Object target,
                     org.springframework.validation.Errors errors)
Perform actual validation. Delegate to the validation manager, and then provide the flow and state id to the doManualValidation method in case the user has some specific things needing validation.

Specified by:
validate in interface org.springframework.validation.Validator
Parameters:
target - the base object to validate
errors - the Errors object on which to record errors.

doManualValidation

public void doManualValidation(String flowId,
                               String stateId,
                               Object target,
                               org.springframework.validation.Errors errors)
Overload doManualValidation if it is wished to perform validation in addition to what is specified in the rules.

Parameters:
flowId - Provides the Web Flow Flow ID.
stateId - Provides the Web Flow State ID.
target - Provides the Object being validated.
errors - Provides an Errors interface for recording validation messages.


Copyright © 2013 Spring Jutsu. All Rights Reserved.