org.apache.tapestry.form.validator
Class AbstractValidatorWrapper

java.lang.Object
  extended by org.apache.tapestry.form.validator.AbstractValidatorWrapper
All Implemented Interfaces:
FormComponentContributor, Validator
Direct Known Subclasses:
BeanValidatorWrapper

public abstract class AbstractValidatorWrapper
extends Object
implements Validator

Abstract implementation of Validator that delegates to some other object.

Since:
4.0
Author:
Howard Lewis Ship

Constructor Summary
AbstractValidatorWrapper()
           
 
Method Summary
 boolean getAcceptsNull()
          Returns true if this validator accepts null as the object parameter to validate().
protected abstract  Validator getDelegate()
           
 boolean isRequired()
          Returns true if this field is required.
 void renderContribution(IMarkupWriter writer, IRequestCycle cycle, FormComponentContributorContext context, IFormComponent field)
          Invoked by a form component after it finishes rendering its tag (but before the tag is closed) to allow this object to contribute to the component's rendering process.
 void validate(IFormComponent field, ValidationMessages messages, Object object)
          Invoked to validate input for the field.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractValidatorWrapper

public AbstractValidatorWrapper()
Method Detail

getDelegate

protected abstract Validator getDelegate()

validate

public void validate(IFormComponent field,
                     ValidationMessages messages,
                     Object object)
              throws ValidatorException
Description copied from interface: Validator
Invoked to validate input for the field. A Translator will have already converted the submitted user input string into an object.

Specified by:
validate in interface Validator
Parameters:
field - the form element component being validated, often used to determine the user presentable name for the field, used in error messages.
messages - access to the pre-defined validation messages, in the appropriate locale
object - the client-side representation of the field's data. May be null if the client did not provide a value for the field (most Validators should check for null and perform no check if null).
Throws:
ValidatorException - if the object violates the constraint represented by this Validator.

getAcceptsNull

public boolean getAcceptsNull()
Description copied from interface: Validator
Returns true if this validator accepts null as the object parameter to validate(). When the object is null, validators that can't accept null are skipped. It is rare for a validator to return true.

Specified by:
getAcceptsNull in interface Validator

isRequired

public boolean isRequired()
Description copied from interface: Validator
Returns true if this field is required. Returns false otherwise.

Specified by:
isRequired in interface Validator

renderContribution

public void renderContribution(IMarkupWriter writer,
                               IRequestCycle cycle,
                               FormComponentContributorContext context,
                               IFormComponent field)
Description copied from interface: FormComponentContributor
Invoked by a form component after it finishes rendering its tag (but before the tag is closed) to allow this object to contribute to the component's rendering process. Typically used by Validators and Translators to add javascript methods to the form's submit event handler.

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


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