|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectwicket.markup.html.form.validation.AbstractValidator
public abstract class 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(FormComponent ...) 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 key that is used to get
the message defaults to the pattern:
[form-name].[component-name].[validator-class]. For example:
MyForm.name.RequiredValidator=A name is required.
Error message string resources can contain optional property variable interpolations from the component, such as:
editBook.name.LengthValidator='${input}' is too short a name.
Available variables for interpolation are:
| Constructor Summary | |
|---|---|
AbstractValidator()
|
|
| Method Summary | |
|---|---|
void |
error(FormComponent formComponent)
Sets an error on the component being validated using the map returned by messageModel() for variable interpolations. |
void |
error(FormComponent formComponent,
java.util.Map map)
Sets an error on the component being validated using the given map for variable interpolations. |
void |
error(FormComponent formComponent,
java.lang.String resourceKey,
IModel resourceModel)
Returns a formatted validation error message for a given component. |
void |
error(FormComponent formComponent,
java.lang.String resourceKey,
java.util.Map map)
Sets an error on the component being validated using the given map for variable interpolations. |
protected java.util.Map |
messageModel(FormComponent formComponent)
Gets the default variables for interpolation. |
protected java.lang.String |
resourceKey(FormComponent formComponent)
Gets the resource key for validator's error message from the ApplicationSettings class. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface wicket.markup.html.form.validation.IValidator |
|---|
validate |
| Constructor Detail |
|---|
public AbstractValidator()
| Method Detail |
|---|
public void error(FormComponent formComponent)
See class comments for details about how error messages are loaded and formatted.
formComponent - form component
public void error(FormComponent formComponent,
java.lang.String resourceKey,
java.util.Map map)
formComponent - form componentresourceKey - The resource key to usemap - The model for variable interpolation
public void error(FormComponent formComponent,
java.util.Map map)
formComponent - form componentmap - The model for variable interpolation
public void error(FormComponent formComponent,
java.lang.String resourceKey,
IModel resourceModel)
formComponent - form componentresourceKey - The resource key to useresourceModel - The model for variable interpolation, it needs to have a map inside it.protected java.lang.String resourceKey(FormComponent formComponent)
formComponent - form component that is being validated
protected java.util.Map messageModel(FormComponent formComponent)
formComponent - form component
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||