org.apache.tapestry.form.validator
Class Identity

java.lang.Object
  extended by org.apache.tapestry.form.validator.BaseValidator
      extended by org.apache.tapestry.form.validator.Identity
All Implemented Interfaces:
FormComponentContributor, Validator

public class Identity
extends BaseValidator

Validates that the input value is the same as the value of another field. This validator can also work in 'differ' mode.

Apply this validator to the second field in question and define the name of the component against which to compare the current value.

Since:
4.1.2

Constructor Summary
Identity()
           
Identity(String initializer)
           
 
Method Summary
protected  String buildIdentityMessage(ValidationMessages messages, IFormComponent field, IFormComponent referent)
           
 String getDiffer()
           
 String getMatch()
           
 void renderContribution(IMarkupWriter writer, IRequestCycle cycle, FormComponentContributorContext context, IFormComponent field)
          Does nothing.
 void setDiffer(String field)
           
 void setMatch(String field)
           
 String toString(IFormComponent field, Object value)
           
 void validate(IFormComponent field, ValidationMessages messages, Object object)
          Invoked to validate input for the field.
 
Methods inherited from class org.apache.tapestry.form.validator.BaseValidator
accumulateProfileProperty, accumulateProperty, getAcceptsNull, getFieldTranslator, getMessage, isRequired, setMessage
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Identity

public Identity()

Identity

public Identity(String initializer)
Method Detail

toString

public String toString(IFormComponent field,
                       Object value)

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.

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.

renderContribution

public void renderContribution(IMarkupWriter writer,
                               IRequestCycle cycle,
                               FormComponentContributorContext context,
                               IFormComponent field)
Description copied from class: BaseValidator
Does nothing.

Specified by:
renderContribution in interface FormComponentContributor
Overrides:
renderContribution in class BaseValidator
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

getMatch

public String getMatch()

setMatch

public void setMatch(String field)

getDiffer

public String getDiffer()

setDiffer

public void setDiffer(String field)

buildIdentityMessage

protected String buildIdentityMessage(ValidationMessages messages,
                                      IFormComponent field,
                                      IFormComponent referent)


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