|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectwicket.markup.html.form.validation.AbstractValidator
Base class for form component validators. This class is thread-safe and therefore it is safe to share validators across sessions/threads.
Error messages can be registered on a component by calling one of the error() overloads. The error message will be retrieved using the Localizer for the form component. Normally, this localizer will find the error message in a string resource bundle (properties file) associated with the page in which this validator is contained. The resource key must be of the form: [form-name].[component-name].[validator-class]. For example:
MyForm.name.RequiredValidator=A name is required.
Error message string resources can contain optional ognl variable interpolations from the component, such as:
editBook.name.LengthValidator='${input}' is too short a name.
Available variables for interpolation are:
| Nested Class Summary |
| Nested classes inherited from class wicket.markup.html.form.validation.IValidator |
IValidator.NullValidator |
| Field Summary |
| Fields inherited from interface wicket.markup.html.form.validation.IValidator |
NULL |
| Constructor Summary | |
AbstractValidator()
|
|
| Method Summary | |
void |
error()
Sets an error on the component being validated using the map returned by messageModel() for variable interpolations. |
void |
error(java.util.Map map)
Sets an error on the component being validated using the given map for variable interpolations. |
void |
error(java.lang.String resourceKey,
IModel resourceModel)
Returns a formatted validation error message for a given component. |
void |
error(java.lang.String resourceKey,
java.util.Map map)
Sets an error on the component being validated using the given map for variable interpolations. |
FormComponent |
getFormComponent()
|
java.lang.String |
getInput()
|
protected java.util.Map |
messageModel()
Gets the default variables for interpolation. |
abstract void |
onValidate()
Implemented by subclasses to validate component |
protected java.lang.String |
resourceKey()
Gets the resource key based on the form component. |
void |
validate(FormComponent formComponent)
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. |
| 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 void error()
See class comments for details about how error messages are loaded and formatted.
public void error(java.lang.String resourceKey,
IModel resourceModel)
resourceKey - The resource key to useresourceModel - The model for variable interpolation
public void error(java.lang.String resourceKey,
java.util.Map map)
resourceKey - The resource key to usemap - The model for variable interpolationpublic void error(java.util.Map map)
map - The model for variable interpolationpublic FormComponent getFormComponent()
public java.lang.String getInput()
public abstract void onValidate()
public final void validate(FormComponent formComponent)
IValidatorInstead of subclassing IValidator, you should use one of the existing validators, which cover a huge number of cases, or if none satisfies your need, subclass CustomValidator.
Validates the given input. The input corresponds to the input from the request for a component. Any implementation of this method should be synchronized because validators are intended to be shared across sessions/threads.
validate in interface IValidatorformComponent - Component to validateIValidator.validate(wicket.markup.html.form.FormComponent)protected java.util.Map messageModel()
protected java.lang.String resourceKey()
[form-name].[component-name].[validator-class]
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||