com.primix.tapestry.valid
Interface IValidationDelegate

All Known Implementing Classes:
BaseValidationDelegate

public interface IValidationDelegate

Interface used to communicate errors from an IValidatingTextField component to some application-specific code. In addition, controls how fields that are in error are presented (they can be marked in various ways by the delegate; the default implementation adds to red asterisks to the right of the field).

The interface is designed so that a single instance can be shared with many instances of IValidatingTextField.

TBD: Add another method so that the delegate can write additional attributes into the text field (i.e., to change its color or class).

Version:
$Id: IValidationDelegate.java,v 1.4 2001/08/23 20:19:32 hship Exp $
Author:
Howard Ship

Method Summary
 void invalidField(IValidatingTextField field, ValidationConstraint constraint, java.lang.String defaultErrorMessage)
          The error notification method, invoked during the rewind phase (that is, while HTTP parameters are being extracted from the request and assigned to various object properties).
 void writeAttributes(IValidatingTextField field, IResponseWriter writer, IRequestCycle cycle)
          Invoked just before the <input type=text> element is closed.
 void writeErrorPrefix(IValidatingTextField field, IResponseWriter writer, IRequestCycle cycle)
          Invoked before the field is rendered, if the field is in error.
 void writeErrorSuffix(IValidatingTextField field, IResponseWriter writer, IRequestCycle cycle)
          Invoked after the field is rendered, if the field is in error.
 void writeLabelPrefix(IValidatingTextField field, IResponseWriter writer, IRequestCycle cycle)
          Invoked by a FieldLabel just before writing the name of the field.
 void writeLabelSuffix(IValidatingTextField field, IResponseWriter writer, IRequestCycle cycle)
          Invoked by a FieldLabel just after writing the name of the field.
 

Method Detail

invalidField

public void invalidField(IValidatingTextField field,
                         ValidationConstraint constraint,
                         java.lang.String defaultErrorMessage)
The error notification method, invoked during the rewind phase (that is, while HTTP parameters are being extracted from the request and assigned to various object properties).

Typically, the listener simply arrainges to present the defaultErrorMessage to the user (as part of the HTML response). Finicky listeners may, instead, use the constraint and displayName (from the field) to form their own error message.

Parameters:
field - the field to which the update applies to.
constraint - the ValidationConstraint which was violated.
defaultErrorMessage - a default, localized, error message.

writeErrorPrefix

public void writeErrorPrefix(IValidatingTextField field,
                             IResponseWriter writer,
                             IRequestCycle cycle)
                      throws RequestCycleException
Invoked before the field is rendered, if the field is in error.

writeAttributes

public void writeAttributes(IValidatingTextField field,
                            IResponseWriter writer,
                            IRequestCycle cycle)
                     throws RequestCycleException
Invoked just before the <input type=text> element is closed. The delete can write additional attributes. This is often used to set the CSS class of the field so that it can be displayed differently, if in error (or required).
Since:
1.0.5

writeErrorSuffix

public void writeErrorSuffix(IValidatingTextField field,
                             IResponseWriter writer,
                             IRequestCycle cycle)
                      throws RequestCycleException
Invoked after the field is rendered, if the field is in error.

writeLabelPrefix

public void writeLabelPrefix(IValidatingTextField field,
                             IResponseWriter writer,
                             IRequestCycle cycle)
                      throws RequestCycleException
Invoked by a FieldLabel just before writing the name of the field.

writeLabelSuffix

public void writeLabelSuffix(IValidatingTextField field,
                             IResponseWriter writer,
                             IRequestCycle cycle)
                      throws RequestCycleException
Invoked by a FieldLabel just after writing the name of the field.