|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.wicket.behavior.Behavior org.apache.wicket.validation.validator.AbstractValidator<T>
T
- type of validatablepublic abstract class AbstractValidator<T>
Convenience base class for IValidator
s. This class is thread-safe and therefore it is
safe to share validators across sessions/threads.
Error messages can be registered by calling one of the error (IValidatable
)
overloads. By default this class will skip validation if the IValidatable.getValue()
returns null
. Validators that wish to validate the null
value need to
override validateOnNullValue()
and return true
.
Constructor Summary | |
---|---|
AbstractValidator()
|
Method Summary | |
---|---|
void |
error(IValidatable<T> validatable)
Reports an error against an IValidatable instance using the Map
returned by variablesMap(IValidatable) for variable interpolations and the message
resource key returned by resourceKey() . |
void |
error(IValidatable<T> validatable,
Map<String,Object> vars)
Reports an error against an IValidatable instance using the given
Map for variable interpolations and message resource key provided by
resourceKey() . |
void |
error(IValidatable<T> validatable,
String resourceKey)
Reports an error against an IValidatable instance using the Map
returned by variablesMap(IValidatable) for variable interpolations and the given
message resource key. |
void |
error(IValidatable<T> validatable,
String resourceKey,
Map<String,Object> vars)
Reports an error against an IValidatable instance using the given message
resource key and Map for variable interpolations. |
protected abstract void |
onValidate(IValidatable<T> validatable)
Validates the IValidatable instance. |
protected String |
resourceKey()
Gets the message resource key for this validator's error message from the ApplicationSettings class. |
void |
validate(IValidatable<T> validatable)
Validates the IValidatable instance. |
boolean |
validateOnNullValue()
Indicates whether or not to validate the value if it is null . |
protected Map<String,Object> |
variablesMap(IValidatable<T> validatable)
Gets the default Map of variables. |
Methods inherited from class org.apache.wicket.behavior.Behavior |
---|
afterRender, beforeRender, bind, canCallListenerInterface, canCallListenerInterface, detach, getStatelessHint, isEnabled, isTemporary, onComponentTag, onConfigure, onEvent, onException, renderHead, unbind |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public AbstractValidator()
Method Detail |
---|
public boolean validateOnNullValue()
null
. It is usually
desirable to skip validation if the value is null
, unless we want to make sure
the value is in fact null
(a rare use case). Validators that extend this and
wish to ensure the value is null
should override this method and return
true
.
true
to validate on null
value, false
to skip
validation on null
valueprotected abstract void onValidate(IValidatable<T> validatable)
IValidatable
instance.
validatable
- the given IValidatable
instancepublic final void validate(IValidatable<T> validatable)
IValidator
IValidatable
instance. Validation errors should be reported using
the IValidatable.error(IValidationError)
method.
validate
in interface IValidator<T>
validatable
- the IValidatable
instance being validatedIValidator.validate(IValidatable)
public void error(IValidatable<T> validatable)
IValidatable
instance using the Map
returned by variablesMap(IValidatable)
for variable interpolations and the message
resource key returned by resourceKey()
.
validatable
- the IValidatable
instance being validatedpublic void error(IValidatable<T> validatable, String resourceKey)
IValidatable
instance using the Map
returned by variablesMap(IValidatable)
for variable interpolations and the given
message resource key.
validatable
- the IValidatable
instance being validatedresourceKey
- the message resource key to usepublic void error(IValidatable<T> validatable, Map<String,Object> vars)
IValidatable
instance using the given
Map
for variable interpolations and message resource key provided by
resourceKey()
.
validatable
- the IValidatable
instance being validatedvars
- Map
of variables for variable interpolationpublic void error(IValidatable<T> validatable, String resourceKey, Map<String,Object> vars)
IValidatable
instance using the given message
resource key and Map
for variable interpolations.
validatable
- the IValidatable
instance being validatedresourceKey
- the message resource key to usevars
- Map
of variables for variable interpolationprotected String resourceKey()
ApplicationSettings
class.
NOTE: THIS METHOD SHOULD NEVER RETURN null
.
protected Map<String,Object> variablesMap(IValidatable<T> validatable)
Map
of variables.
NOTE: THIS METHOD SHOULD NEVER RETURN null
.
validatable
- the IValidatable
instance being validated
Map
of variables for variable interpolation
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |