it.eng.spago.validation.fieldvalidators
Class AbstractFieldValidator

java.lang.Object
  extended by it.eng.spago.dispatching.service.DefaultRequestContext
      extended by it.eng.spago.validation.fieldvalidators.AbstractFieldValidator
All Implemented Interfaces:
RequestContextIFace, FieldValidatorIFace, java.io.Serializable
Direct Known Subclasses:
AlphaNumericValidator, DateValidator, EMailValidator, FiscalCodeValidator, GenericFieldValidator, LetterStringValidator, NameValidator, NumericValidator, RegExpValidator, UrlValidator

public abstract class AbstractFieldValidator
extends DefaultRequestContext
implements FieldValidatorIFace

Author:
zoppello An abstract class that implements FieldValidatorIFace, in this class there is the code for handling of the TYPED_SERVICE_REQUEST source bean that will contains the field with alias after the validation
See Also:
Serialized Form

Field Summary
static java.lang.String DEFAULT_VALUE_IDENTIFIER
           
static java.lang.String GENERIC_ERROR_IDENTIFIER
           
 
Constructor Summary
AbstractFieldValidator()
           
 
Method Summary
 SourceBean getConfig()
          The getter method for the configuration of the field Validator
 java.lang.String getParameter(java.lang.String paramName, java.lang.String defaultValue, java.util.Map fieldValidationParams)
          Retrieve a parameter from the field configuration (if present) or from the validator configuration
 java.lang.String getUserFieldName(java.lang.String fieldName)
          Return the field name used in error messages.
 void init(SourceBean config)
          Initialize The validator with his configuration
 void saveTypedValue(SourceBean serviceRequest, java.lang.String name, java.lang.Object value)
          Save in the Typed Service Request the attribute with name and value Subclasses must use this method to save the field converted with typed value and alias
 boolean setDefault(SourceBean serviceRequest, java.lang.String fieldName, java.util.Map fieldValidationParams)
          Set the default value on the field, if configured
 
Methods inherited from class it.eng.spago.dispatching.service.DefaultRequestContext
getErrorHandler, getRequestContainer, getResponseContainer, getServiceRequest, getServiceResponse, setRequestContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface it.eng.spago.validation.FieldValidatorIFace
validateField
 

Field Detail

GENERIC_ERROR_IDENTIFIER

public static final java.lang.String GENERIC_ERROR_IDENTIFIER
See Also:
Constant Field Values

DEFAULT_VALUE_IDENTIFIER

public static final java.lang.String DEFAULT_VALUE_IDENTIFIER
See Also:
Constant Field Values
Constructor Detail

AbstractFieldValidator

public AbstractFieldValidator()
Method Detail

saveTypedValue

public void saveTypedValue(SourceBean serviceRequest,
                           java.lang.String name,
                           java.lang.Object value)
Save in the Typed Service Request the attribute with name and value Subclasses must use this method to save the field converted with typed value and alias

Parameters:
serviceRequest - The Spago Service Request
name - The name of the attribute to store
value - The value to store

getConfig

public SourceBean getConfig()
The getter method for the configuration of the field Validator

Specified by:
getConfig in interface FieldValidatorIFace
See Also:
FieldValidatorIFace.getConfig()

init

public void init(SourceBean config)
Initialize The validator with his configuration

Specified by:
init in interface FieldValidatorIFace
See Also:
FieldValidatorIFace.init(it.eng.spago.base.SourceBean)

getParameter

public java.lang.String getParameter(java.lang.String paramName,
                                     java.lang.String defaultValue,
                                     java.util.Map fieldValidationParams)
Retrieve a parameter from the field configuration (if present) or from the validator configuration

Returns:
The value for this parameter.

getUserFieldName

public java.lang.String getUserFieldName(java.lang.String fieldName)
Return the field name used in error messages.

Parameters:
fieldName - Name of the field in the form.
Returns:
Field name used in error messages.

setDefault

public boolean setDefault(SourceBean serviceRequest,
                          java.lang.String fieldName,
                          java.util.Map fieldValidationParams)
                   throws EMFValidationError
Description copied from interface: FieldValidatorIFace
Set the default value on the field, if configured

Specified by:
setDefault in interface FieldValidatorIFace
Parameters:
serviceRequest - Service request
fieldName - Field name
fieldValidationParams - Configuration parameters
Returns:
true if the default value was setted
Throws:
EMFValidationError