V - The class name of the view being validated.public class ViewValidator<V> extends Object
© Copyright 2008 Sans Pareil Technologies, Inc.
| Modifier and Type | Field and Description |
|---|---|
protected Map<String,Field> |
fields
The map of all fields in
view. |
protected V |
view
The view whose child components are to be validated.
|
| Modifier | Constructor and Description |
|---|---|
protected |
ViewValidator()
Default constructor.
|
|
ViewValidator(V view)
Create a new instance of the validator for the specified view.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
checkConfirm(String value,
Constraints constraint,
String name,
Collection<String> messages)
Check a secondary field value with the
value for equality. |
protected void |
checkText(String text,
String name,
Collection<String> messages)
Check the specified text for non-null.
|
protected void |
processListComponent(AbstractListComponent component,
Constraints constraint,
String name,
Collection<String> messages)
Check the specified list component and ensure that at least one value
is selected if annotated as mandatory.
|
protected void |
processRegex(Constraints constraint,
String value,
String name,
Collection<String> messages)
Process the
Constraints.regex() value
and apply to the value in the field. |
protected void |
processTextComponent(TextComponent component,
Constraints constraint,
String name,
Collection<String> messages)
Process a
TextComponent against its
annotated constraints. |
Collection<String> |
validate()
Perform the validation on the child components.
|
protected final V view
protected ViewValidator()
public ViewValidator(V view)
view - The view to be validated.public Collection<String> validate()
processTextComponent(nextapp.echo.app.text.TextComponent, com.sptci.echo.annotation.Constraints, java.lang.String, java.util.Collection<java.lang.String>),
processListComponent(nextapp.echo.app.list.AbstractListComponent, com.sptci.echo.annotation.Constraints, java.lang.String, java.util.Collection<java.lang.String>)protected void processTextComponent(TextComponent component, Constraints constraint, String name, Collection<String> messages)
TextComponent against its
annotated constraints.component - The text component being validated.constraint - The annotated constraint.name - The name of the field in view that is being
processed.messages - The collection to which any localised error messages
are added.checkText(java.lang.String, java.lang.String, java.util.Collection<java.lang.String>),
processRegex(com.sptci.echo.annotation.Constraints, java.lang.String, java.lang.String, java.util.Collection<java.lang.String>)protected void checkText(String text, String name, Collection<String> messages)
messages collection. The localised message is
retrieved using the following name:
<View.getClass().getName()>.<field name>.empty.error
text - The text value that is to be checked.name - The name of the field in view that is being checked.messages - The collection to which error messages will be added
as appropriate.checkConfirm(java.lang.String, com.sptci.echo.annotation.Constraints, java.lang.String, java.util.Collection<java.lang.String>)protected void checkConfirm(String value, Constraints constraint, String name, Collection<String> messages)
value for equality.
If the check fails a localised message is added to the
messages collection. The localised message is retrieved
using the following name:
<View.getClass().getName()>.<name>.confirm.error
value - The value in the field that is to be checked.constraint - The annotated constraint for the field.name - The name of the field.messages - The collection to which error messages will be added.protected void processRegex(Constraints constraint, String value, String name, Collection<String> messages)
Constraints.regex() value
and apply to the value in the field. If the regex does not match the
value, a localised message is added to the messages
collection. The localised message is retrieved using the following
name:
<View.getClass().getName()>.<field name>.regex.error
constraint - The annotatated constraint for the field being
processed.value - The value in the field that is being validated.name - The name of the field in view that is being checked.messages - The collection to which any localised error messages
are added.protected void processListComponent(AbstractListComponent component, Constraints constraint, String name, Collection<String> messages)
messages collection. The
localised message is retrieved using the following name:
<View.getClass().getName()>.<field name>.empty.error
component - The list component that is to be checked.constraint - The annotated constraint on the list component.name - The name of the field in view that is being checked.messages - The collection to which error message will be added
as appropriate.