|
|||||||||
| Home >> All >> org >> apache >> tapestry >> [ valid overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.apache.tapestry.valid
Class ValidationDelegate

java.lang.Objectorg.apache.tapestry.valid.ValidationDelegate
- All Implemented Interfaces:
- IValidationDelegate
- public class ValidationDelegate
- extends java.lang.Object
- implements IValidationDelegate
- extends java.lang.Object
A base implementation of IValidationDelegate that can be used as a helper bean. This class is often subclassed, typically to override presentation details.
- Since:
- 1.0.5
| Field Summary | |
static com.cortexeb.tools.clover.d |
__CLOVER_461_0
|
private org.apache.tapestry.form.IFormComponent |
_currentComponent
|
private java.util.Map |
_trackingMap
A Map of Maps, keyed on the name of the Form. |
private java.util.List |
_trackings
|
| Constructor Summary | |
ValidationDelegate()
|
|
| Method Summary | |
void |
clear()
Clears all tracking information. |
protected FieldTracking |
findCurrentTracking()
Finds or creates the field tracking for the setFormComponent(IFormComponent) 55 current component. |
java.util.List |
getAssociatedTrackings()
Returns a java.util.List of IFieldTrackings. |
protected FieldTracking |
getComponentTracking()
Returns the IFieldTracking for the current component, if any. |
java.lang.String |
getFieldInputValue()
Returns the string submitted by the client as the value for the current field. |
java.util.List |
getFieldTracking()
Returns all the field trackings as an unmodifiable List. |
org.apache.tapestry.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. |
java.util.List |
getUnassociatedTrackings()
Like getAssociatedTrackings() 55 , 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(org.apache.tapestry.form.IFormComponent component)
Checks to see if the field is in error. |
void |
record(org.apache.tapestry.IRender errorRenderer,
ValidationConstraint constraint)
Records error information about the currently selected component, or records unassociated (with any field) errors. |
void |
record(java.lang.String message,
ValidationConstraint constraint)
Invokes record(IRender, ValidationConstraint) 55 , after
wrapping the message parameter in a
RenderString. |
void |
record(ValidatorException ex)
Invokes record(String, ValidationConstraint) 55 , or
record(IRender, ValidationConstraint) 55 if the
error renderer property 55
is not null. |
void |
recordFieldInputValue(java.lang.String input)
Records the user's input for the current form component. |
void |
reset()
Resets any tracking information for the current field. |
void |
setFormComponent(org.apache.tapestry.form.IFormComponent component)
Invoked before other methods to configure the delegate for the given form component. |
void |
writeAttributes(org.apache.tapestry.IMarkupWriter writer,
org.apache.tapestry.IRequestCycle cycle,
org.apache.tapestry.form.IFormComponent component,
IValidator validator)
Does nothing. |
void |
writeLabelPrefix(org.apache.tapestry.form.IFormComponent component,
org.apache.tapestry.IMarkupWriter writer,
org.apache.tapestry.IRequestCycle cycle)
If the form component is in error, places a <font color="red"< around it. |
void |
writeLabelSuffix(org.apache.tapestry.form.IFormComponent component,
org.apache.tapestry.IMarkupWriter writer,
org.apache.tapestry.IRequestCycle cycle)
Closes the <font> element,started by writeLabelPrefix(IFormComponent,IMarkupWriter,IRequestCycle) 55 ,
if the form component is in error. |
void |
writePrefix(org.apache.tapestry.IMarkupWriter writer,
org.apache.tapestry.IRequestCycle cycle,
org.apache.tapestry.form.IFormComponent component,
IValidator validator)
Does nothing. |
void |
writeSuffix(org.apache.tapestry.IMarkupWriter writer,
org.apache.tapestry.IRequestCycle cycle,
org.apache.tapestry.form.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 |
| Field Detail |
__CLOVER_461_0
public static com.cortexeb.tools.clover.d __CLOVER_461_0
_currentComponent
private org.apache.tapestry.form.IFormComponent _currentComponent
_trackings
private java.util.List _trackings
_trackingMap
private java.util.Map _trackingMap
- A Map of Maps, keyed on the name of the Form. Each inner map contains
the trackings for one form, keyed on component name. Care must
be taken, because the inner Map is not always present.
| Constructor Detail |
ValidationDelegate
public ValidationDelegate()
| Method Detail |
clear
public void clear()
- Description copied from interface:
IValidationDelegate - Clears all tracking information.
- Specified by:
clearin interfaceIValidationDelegate
writeLabelPrefix
public void writeLabelPrefix(org.apache.tapestry.form.IFormComponent component, org.apache.tapestry.IMarkupWriter writer, org.apache.tapestry.IRequestCycle cycle)
- If the form component is in error, places a <font color="red"< around it.
Note: this will only work on the render phase after a rewind, and will be
confused if components are inside any kind of loop.
- Specified by:
writeLabelPrefixin interfaceIValidationDelegate
writeLabelSuffix
public void writeLabelSuffix(org.apache.tapestry.form.IFormComponent component, org.apache.tapestry.IMarkupWriter writer, org.apache.tapestry.IRequestCycle cycle)
- Closes the <font> element,started by
writeLabelPrefix(IFormComponent,IMarkupWriter,IRequestCycle)55 , if the form component is in error.- Specified by:
writeLabelSuffixin interfaceIValidationDelegate
getComponentTracking
protected FieldTracking getComponentTracking()
- Returns the IFieldTracking for the current component, if any.
The IFieldTracking is usually created in
record(String, ValidationConstraint)55 or inrecord(IRender, ValidationConstraint)55 .Components may be rendered multiple times, with multiple names (provided by the org.apache.tapestry.form.Form, care must be taken that this method is invoked after the Form has provided a unique IFormComponent.getName()>
IFormComponent.getName()55 for the component.
setFormComponent
public void setFormComponent(org.apache.tapestry.form.IFormComponent component)
- Description copied from interface:
IValidationDelegate - Invoked before other methods to configure the delegate for the given
form component. Sets the current field based on
the name 55 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).
- Specified by:
setFormComponentin interfaceIValidationDelegate
isInError
public boolean isInError()
- Description copied from interface:
IValidationDelegate - Returns true if the current component is in error (that is, had bad input
submitted by the end user).
- Specified by:
isInErrorin interfaceIValidationDelegate
getFieldInputValue
public java.lang.String getFieldInputValue()
- Description copied from interface:
IValidationDelegate - Returns the string submitted by the client as the value for
the current field.
- Specified by:
getFieldInputValuein interfaceIValidationDelegate
getFieldTracking
public java.util.List getFieldTracking()
- Returns all the field trackings as an unmodifiable List.
- Specified by:
getFieldTrackingin interfaceIValidationDelegate
reset
public void reset()
- Description copied from interface:
IValidationDelegate - Resets any tracking information for the current field. This will
clear the field's inError flag, and set its error message and invalid input value
to null.
- Specified by:
resetin interfaceIValidationDelegate
record
public void record(ValidatorException ex)
- Invokes
record(String, ValidationConstraint)55 , orrecord(IRender, ValidationConstraint)55 if the error renderer property 55 is not null.- Specified by:
recordin interfaceIValidationDelegate
record
public void record(java.lang.String message, ValidationConstraint constraint)
- Invokes
record(IRender, ValidationConstraint)55 , after wrapping the message parameter in a RenderString.- Specified by:
recordin interfaceIValidationDelegate
record
public void record(org.apache.tapestry.IRender errorRenderer, ValidationConstraint constraint)
- Records error information about the currently selected component,
or records unassociated (with any field) errors.
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.
- Specified by:
recordin interfaceIValidationDelegate
- Since:
- 1.0.9
recordFieldInputValue
public void recordFieldInputValue(java.lang.String input)
- Description copied from interface:
IValidationDelegate - Records the user's input for the current form component. Input should
be recorded even if there isn't an explicit error, since later form-wide
validations may discover an error in the field.
- Specified by:
recordFieldInputValuein interfaceIValidationDelegate
findCurrentTracking
protected FieldTracking findCurrentTracking()
- Finds or creates the field tracking for the
setFormComponent(IFormComponent)55 current component. If no current component, an unassociated error is created and returned.- Since:
- 3.0
writePrefix
public void writePrefix(org.apache.tapestry.IMarkupWriter writer, org.apache.tapestry.IRequestCycle cycle, org.apache.tapestry.form.IFormComponent component, IValidator validator)
- Does nothing. Override in a subclass to decoreate
fields.
- Specified by:
writePrefixin interfaceIValidationDelegate
writeAttributes
public void writeAttributes(org.apache.tapestry.IMarkupWriter writer, org.apache.tapestry.IRequestCycle cycle, org.apache.tapestry.form.IFormComponent component, IValidator validator)
- Does nothing. Override in a subclass to decorate fields.
- Specified by:
writeAttributesin interfaceIValidationDelegate
writeSuffix
public void writeSuffix(org.apache.tapestry.IMarkupWriter writer, org.apache.tapestry.IRequestCycle cycle, org.apache.tapestry.form.IFormComponent component, IValidator validator)
- Default implementation; if the current field is in error,
then a suffix is written. The suffix is:
<font color="red">**</font>.- Specified by:
writeSuffixin interfaceIValidationDelegate
getHasErrors
public boolean getHasErrors()
- Description copied from interface:
IValidationDelegate - Returns true if any form component has errors.
- Specified by:
getHasErrorsin interfaceIValidationDelegate
getFirstError
public org.apache.tapestry.IRender getFirstError()
- A convienience, as most pages just show the first error on the page.
As of release 1.0.9, this returns an instance of org.apache.tapestry.IRender, not a java.lang.String.
isInError
protected boolean isInError(org.apache.tapestry.form.IFormComponent component)
- Checks to see if the field is in error. This will not work properly
in a loop, but is only used by FieldLabel. Therefore, using FieldLabel
in a loop (where the org.apache.tapestry.form.IFormComponent is renderred more than once) will not provide
correct results.
getAssociatedTrackings
public java.util.List getAssociatedTrackings()
- Returns a java.util.List of IFieldTrackings. 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).
getUnassociatedTrackings
public java.util.List getUnassociatedTrackings()
- Like
getAssociatedTrackings()55 , 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).
|
|||||||||
| Home >> All >> org >> apache >> tapestry >> [ valid overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
org.apache.tapestry.valid.ValidationDelegate