org.apache.tapestry.form.validator
Class BaseValidator

java.lang.Object
  extended by org.apache.tapestry.form.validator.BaseValidator
All Implemented Interfaces:
FormComponentContributor, Validator
Direct Known Subclasses:
Email, Identity, Max, MaxDate, MaxLength, Min, MinDate, MinLength, Pattern, Required

public abstract class BaseValidator
extends Object
implements Validator

Abstract implementation of Validator.

Since:
4.0
Author:
Howard Lewis Ship

Constructor Summary
BaseValidator()
           
BaseValidator(String initializer)
           
 
Method Summary
 void accumulateProfileProperty(IFormComponent field, JSONObject profile, String key, Object property)
          Utility method to store a field specific profile property which can later be used by client side validation.
 void accumulateProperty(JSONObject profile, String key, Object value)
          Utility used to append onto an existing property represented as an object array.
 boolean getAcceptsNull()
          Returns false.
 Translator getFieldTranslator(IFormComponent field, Class clazz)
          Used to grab the corresponding Translator for the field, if one exists.
 String getMessage()
           
 boolean isRequired()
          Returns false.
 void renderContribution(IMarkupWriter writer, IRequestCycle cycle, FormComponentContributorContext context, IFormComponent field)
          Does nothing.
 void setMessage(String message)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.tapestry.form.validator.Validator
validate
 

Constructor Detail

BaseValidator

public BaseValidator()

BaseValidator

public BaseValidator(String initializer)
Method Detail

getMessage

public String getMessage()

setMessage

public void setMessage(String message)

getAcceptsNull

public boolean getAcceptsNull()
Returns false.

Specified by:
getAcceptsNull in interface Validator

renderContribution

public void renderContribution(IMarkupWriter writer,
                               IRequestCycle cycle,
                               FormComponentContributorContext context,
                               IFormComponent field)
Does nothing.

Specified by:
renderContribution in interface FormComponentContributor
Parameters:
writer - allows contributor to write additional attributes into the component's tag
cycle - for accessing request information
context - utilities for genering messages and client-side validation
field - the field for which contributions are being rendered

isRequired

public boolean isRequired()
Returns false. Subclasses may override.

Specified by:
isRequired in interface Validator

accumulateProfileProperty

public void accumulateProfileProperty(IFormComponent field,
                                      JSONObject profile,
                                      String key,
                                      Object property)
Utility method to store a field specific profile property which can later be used by client side validation.

Parameters:
field - The field to store the property for, will key off of IFormComponent.getClientId().
profile - The profile for the form.
key - The property key to store.
property - The property to store.

accumulateProperty

public void accumulateProperty(JSONObject profile,
                               String key,
                               Object value)
Utility used to append onto an existing property represented as an object array.

Parameters:
profile -
key -
value -

getFieldTranslator

public Translator getFieldTranslator(IFormComponent field,
                                     Class clazz)
Used to grab the corresponding Translator for the field, if one exists.

Parameters:
field -
Returns:
The translator, or null if the required translator type doesn't exist.


Copyright © 2006-2008 Apache Software Foundation. All Rights Reserved.