Package 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 input values provided by the user.
- Any validation exceptions associated with input fields.
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
Modifier and TypeMethodDescriptionvoid
clear()
Clears all information stored by the tracker.Returns a previously recorded error message.Returns a list of all error messages.boolean
Returns true if any field contains an error.Returns a previously recorded input value.Returns just the errors that are not associated with any fields.boolean
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
(String errorMessage) Records an error message that is not associated with any specific field.void
recordError
(Field field, String errorMessage) Records an error message for a field.void
recordInput
(Field field, String input) Called by a field to record the exact input from the user, prior to any validation.
-
Method Details
-
recordInput
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 inputinput
- the value obtained from the forms submission
-
getInput
Returns a previously recorded input value. -
recordError
Records an error message for a field. The error message is primarily derived from aValidationException
thrown by aValidator
orTranslator
.- Parameters:
field
-errorMessage
-
-
recordError
Records an error message that is not associated with any specific field. This often reflects some amount of cross-form validation.- Parameters:
errorMessage
-
-
inError
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
Returns a previously recorded error message. -
getHasErrors
boolean getHasErrors()Returns true if any field contains an error. -
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. -
getUnassociatedErrors
Returns just the errors that are not associated with any fields.- Since:
- 5.4
-
clear
void clear()Clears all information stored by the tracker.
-