|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.apache.tapestry.valid.ValidationDelegate
A base implementation of IValidationDelegate
that can be used
as a helper bean. This class is often subclassed, typically to override presentation
details.
Constructor Summary | |
ValidationDelegate()
|
Method Summary | |
void |
clear()
Clears all tracking information. |
protected FieldTracking |
findCurrentTracking()
Finds or creates the field tracking for the setFormComponent(IFormComponent) current component. |
List |
getAssociatedTrackings()
Returns a List of IFieldTracking s. |
protected FieldTracking |
getComponentTracking()
Returns the IFieldTracking for the current component, if any. |
String |
getFieldInputValue()
Returns the string submitted by the client as the value for the current field. |
List |
getFieldTracking()
Returns all the field trackings as an unmodifiable List. |
IRender |
getFirstError()
A convienience, as most pages just show the first error on the page. |
boolean |
getHasErrors()
Returns true if any form component has errors. |
List |
getUnassociatedTrackings()
Like getAssociatedTrackings() , but returns only the unassociated trackings. |
boolean |
isInError()
Returns true if the current component is in error (that is, had bad input submitted by the end user). |
protected boolean |
isInError(IFormComponent component)
Checks to see if the field is in error. |
void |
record(IRender errorRenderer,
ValidationConstraint constraint)
Records error information about the currently selected component, or records unassociated (with any field) errors. |
void |
record(String message,
ValidationConstraint constraint)
Invokes record(IRender, ValidationConstraint) , after
wrapping the message parameter in a
RenderString . |
void |
record(ValidatorException ex)
Invokes record(String, ValidationConstraint) , or
record(IRender, ValidationConstraint) if the
error renderer property
is not null. |
void |
recordFieldInputValue(String input)
Records the user's input for the current form component. |
void |
reset()
Resets any tracking information for the current field. |
void |
setFormComponent(IFormComponent component)
Invoked before other methods to configure the delegate for the given form component. |
void |
writeAttributes(IMarkupWriter writer,
IRequestCycle cycle,
IFormComponent component,
IValidator validator)
Does nothing. |
void |
writeLabelPrefix(IFormComponent component,
IMarkupWriter writer,
IRequestCycle cycle)
If the form component is in error, places a <font color="red"< around it. |
void |
writeLabelSuffix(IFormComponent component,
IMarkupWriter writer,
IRequestCycle cycle)
Closes the <font> element,started by writeLabelPrefix(IFormComponent,IMarkupWriter,IRequestCycle) ,
if the form component is in error. |
void |
writePrefix(IMarkupWriter writer,
IRequestCycle cycle,
IFormComponent component,
IValidator validator)
Does nothing. |
void |
writeSuffix(IMarkupWriter writer,
IRequestCycle cycle,
IFormComponent component,
IValidator validator)
Default implementation; if the current field is in error, then a suffix is written. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public ValidationDelegate()
Method Detail |
public void clear()
IValidationDelegate
clear
in interface IValidationDelegate
public void writeLabelPrefix(IFormComponent component, IMarkupWriter writer, IRequestCycle cycle)
writeLabelPrefix
in interface IValidationDelegate
public void writeLabelSuffix(IFormComponent component, IMarkupWriter writer, IRequestCycle cycle)
writeLabelPrefix(IFormComponent,IMarkupWriter,IRequestCycle)
,
if the form component is in error.
writeLabelSuffix
in interface IValidationDelegate
protected FieldTracking getComponentTracking()
IFieldTracking
for the current component, if any.
The IFieldTracking
is usually created in
record(String, ValidationConstraint)
or
in record(IRender, ValidationConstraint)
.
Components may be rendered multiple times, with multiple names (provided
by the Form
, care must be taken that this method is invoked
after the Form has provided a unique
IFormComponent.getName()
for the component.
FieldTracking
, or null if the field has no tracking.setFormComponent(IFormComponent)
public void setFormComponent(IFormComponent component)
IValidationDelegate
name
of the form component
(which is almost always a ValidField
).
The caller should invoke this with a parameter of null to record unassociated global errors (errors not associated with any particular field).
setFormComponent
in interface IValidationDelegate
public boolean isInError()
IValidationDelegate
isInError
in interface IValidationDelegate
public String getFieldInputValue()
IValidationDelegate
getFieldInputValue
in interface IValidationDelegate
public List getFieldTracking()
getFieldTracking
in interface IValidationDelegate
public void reset()
IValidationDelegate
reset
in interface IValidationDelegate
public void record(ValidatorException ex)
record(String, ValidationConstraint)
, or
record(IRender, ValidationConstraint)
if the
error renderer property
is not null.
record
in interface IValidationDelegate
public void record(String message, ValidationConstraint constraint)
record(IRender, ValidationConstraint)
, after
wrapping the message parameter in a
RenderString
.
record
in interface IValidationDelegate
message
- message to display (@see RenderString}constraint
- the constraint that was violated, or null if not knownpublic void record(IRender errorRenderer, ValidationConstraint constraint)
Currently, you may have at most one error per field (note the difference between field and component), but any number of unassociated errors.
Subclasses may override the default error message (based on other factors, such as the field and constraint) before invoking this implementation.
record
in interface IValidationDelegate
errorRenderer
- object that will render the error message (@see RenderString}constraint
- the constraint that was violated, or null if not knownpublic void recordFieldInputValue(String input)
IValidationDelegate
recordFieldInputValue
in interface IValidationDelegate
protected FieldTracking findCurrentTracking()
setFormComponent(IFormComponent)
current component.
If no current component, an unassociated error is created
and returned.
public void writePrefix(IMarkupWriter writer, IRequestCycle cycle, IFormComponent component, IValidator validator)
writePrefix
in interface IValidationDelegate
public void writeAttributes(IMarkupWriter writer, IRequestCycle cycle, IFormComponent component, IValidator validator)
writeAttributes
in interface IValidationDelegate
public void writeSuffix(IMarkupWriter writer, IRequestCycle cycle, IFormComponent component, IValidator validator)
<font color="red">**</font>
.
writeSuffix
in interface IValidationDelegate
public boolean getHasErrors()
IValidationDelegate
getHasErrors
in interface IValidationDelegate
public IRender getFirstError()
As of release 1.0.9, this returns an instance of IRender
, not a String
.
protected boolean isInError(IFormComponent component)
FieldLabel
. Therefore, using FieldLabel
in a loop (where the IFormComponent
is renderred more than once) will not provide
correct results.
public List getAssociatedTrackings()
List
of IFieldTracking
s. This is the master list
of trackings, except that it omits and trackings that are not associated
with a particular field. May return an empty list, or null.
Order is not determined, though it is likely the order in which components are laid out on in the template (this is subject to change).
public List getUnassociatedTrackings()
getAssociatedTrackings()
, but returns only the unassociated trackings.
Unassociated trackings are new (in release 1.0.9), and are why
interface IFieldTracking
is not very well named.
The trackings are returned in an unspecified order, which (for the moment, anyway) is the order in which they were added (this could change in the future, or become more concrete).
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |