org.apache.tapestry5
Interface ValidationTracker

All Known Implementing Classes:
ValidationTrackerImpl, ValidationTrackerWrapper

public interface ValidationTracker

Tracks information related to user input validations. This information is:

The tracker must differentiate between components (which will implement the Field interfaces) and fields. It is a one to many relationship, because each field may be called upon to render itself multiple times within a request, because of Loop or other similar components.

Internally, the tracker indexes its information in terms of the control name for each rendering of the component (the mechanics of Tapestry ensures that this is unique within the form).

Validation trackers must be serializable, as they will almost always be stored into the HttpSession.

Trackers are used by only a single form within a single page; they are not threadsafe.


Method Summary
 void clear()
          Clears all information stored by the tracker.
 String getError(Field field)
          Returns a previously recorded error message.
 List<String> getErrors()
          Returns a list of all error messages.
 boolean getHasErrors()
          Returns true if any field contains an error.
 String getInput(Field field)
          Returns a previously recorded input value.
 boolean inError(Field field)
          For a given field, determines if the field is "in error", meaning that an error message has been previously recorded for the field.
 void recordError(Field field, String errorMessage)
          Records an error message for a field.
 void recordError(String errorMessage)
          Records an error message that is not associated with any specific field.
 void recordInput(Field field, String input)
          Called by a field to record the exact input from the user, prior to any validation.
 

Method Detail

recordInput

void recordInput(Field field,
                 String input)
Called by a field to record the exact input from the user, prior to any validation. If the form is redisplayed (to present errors), the input value will be sent back to the user for correction.

Parameters:
field - the field recording the input
input - the value obtained from the forms submission

getInput

String getInput(Field field)
Returns a previously recorded input value.


recordError

void recordError(Field field,
                 String errorMessage)
Records an error message for a field. The error message is primarily derived from a ValidationException thrown by a Validator or Translator.

Parameters:
field -
errorMessage -

recordError

void recordError(String errorMessage)
Records an error message that is not associated with any specific field. This often reflects some amount of cross-form validation.

Parameters:
errorMessage -

inError

boolean inError(Field field)
For a given field, determines if the field is "in error", meaning that an error message has been previously recorded for the field.

Parameters:
field -
Returns:
true if an error message is present

getError

String getError(Field field)
Returns a previously recorded error message.


getHasErrors

boolean getHasErrors()
Returns true if any field contains an error.


getErrors

List<String> getErrors()
Returns a list of all error messages. The messages are stored in the order that they were added to the tracker, except that unassociated errors (unassociated with any field) are listed first.


clear

void clear()
Clears all information stored by the tracker.



Copyright © 2003-2012 The Apache Software Foundation.