org.apache.tapestry.valid
Interface IFieldTracking

All Known Implementing Classes:
FieldTracking

public interface IFieldTracking

Defines the interface for an object that tracks input fields. This interface is now poorly named, in that it tracks errors that may not be associated with a specific field.

For each field, a flag is stored indicating if the field is, in fact, in error. The input supplied by the client is stored so that if the form is re-rendered (as is typically done when there are input errors), the value entered by the user can be displayed back to the user. An error message renderer is stored; this is an object that can render the error message (it is usually a RenderString wrapper around a simple string).

Since:
1.0.8
Author:
Howard Lewis Ship

Method Summary
 IFormComponent getComponent()
          Returns the field component.
 ValidationConstraint getConstraint()
          Returns the validation constraint that was violated by the input.
 IRender getErrorRenderer()
          Returns an object that will render the error message.
 String getFieldName()
          Returns the name of the field, that is, the name assigned by the form (this will differ from the component's id when any kind of looping operation is in effect).
 String getInput()
          Returns the invalid input recorded for the field.
 boolean getRenderError()
          Whether or not any errors found should cause field decoration / error renderers to render.
 boolean isInError()
          Returns true if the field is in error (that is, if it has an error message renderer.
 void setRenderError(boolean value)
          Sets whether or not to render errors for this tracking.
 

Method Detail

isInError

boolean isInError()
Returns true if the field is in error (that is, if it has an error message renderer.

Returns:
Whether or not field is in error.

getRenderError

boolean getRenderError()
Whether or not any errors found should cause field decoration / error renderers to render. This is set to false on form submissions (such as a refresh submit) where validation shouldn't cause errors to be rendererd.

Returns:
Whether or not to render errors, default is true.

setRenderError

void setRenderError(boolean value)
Sets whether or not to render errors for this tracking. Gets set to false on form refresh submits.

Parameters:
value - Whether or not to render errors.

getComponent

IFormComponent getComponent()
Returns the field component. This may return null if the error is not associated with any particular field. Note: may return null after the field tracking object is serialized and deserialized (the underlying component reference is transient); this metehod is primarily used for testing.

Returns:
The associated component, or null if not specific to a component.

getErrorRenderer

IRender getErrorRenderer()
Returns an object that will render the error message. The renderer must implement a simple toString() that does not produce markup, but is a simple message.

Returns:
The IRender responsible for rendering the error, or null if none is set.
Since:
1.0.9
See Also:
ValidatorException.ValidatorException(String, IRender, ValidationConstraint)

getInput

String getInput()
Returns the invalid input recorded for the field. This is stored so that, on a subsequent render, the smae invalid input can be presented to the client to be corrected.

Returns:
The original input value.

getFieldName

String getFieldName()
Returns the name of the field, that is, the name assigned by the form (this will differ from the component's id when any kind of looping operation is in effect).

Returns:
The name of the field within the form.

getConstraint

ValidationConstraint getConstraint()
Returns the validation constraint that was violated by the input. This may be null if the constraint isn't known.

Returns:
The associated ValidationConstraint that caused the field error.


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