|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.wicket.validation.Validatable<T>
T - type of validatablepublic class Validatable<T>
This implementation of IValidatable is meant to be used outside of Wicket. It allows
other parts of the application to utilize IValidators for validation.
Example:
class WebService
{
public void addUser(String firstName, String lastName)
{
Validatable standin = new Validatable();
standin.setValue(firstName);
new FirstNameValidator().validate(standin);
standing.setValue(lastName);
new LastNameValidator().validate(standin);
if (!standin.isValid())
{
// roll your own ValidationException
throw new ValidationException(standin.getErrors());
}
else
{
// add user here
}
}
}
| Constructor Summary | |
|---|---|
Validatable()
Constructor. |
|
Validatable(T value)
Constructor. |
|
| Method Summary | |
|---|---|
void |
error(IValidationError error)
Reports an error against this IValidatable's value. |
List<IValidationError> |
getErrors()
Retrieves an unmodifiable list of any errors reported against this IValidatable
instance. |
IModel<T> |
getModel()
Returns the model of the component being validated |
T |
getValue()
Retrieves the value to be validated. |
boolean |
isValid()
Queries the current state of this IValidatable instance. |
void |
setModel(IModel<T> model)
Sets model |
void |
setValue(T value)
Sets the value object that will be returned by getValue(). |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Validatable()
public Validatable(T value)
value - The value that will be tested| Method Detail |
|---|
public void setModel(IModel<T> model)
model - public void setValue(T value)
getValue().
value - the value objectpublic T getValue()
IValidatable
getValue in interface IValidatable<T>IValidatable.getValue()public void error(IValidationError error)
IValidatableIValidatable's value. Multiple errors can be
reported by calling this method multiple times.
error in interface IValidatable<T>error - an IValidationError to be reportedIValidatable.error(IValidationError)public List<IValidationError> getErrors()
IValidatable
instance.
public boolean isValid()
IValidatableIValidatable instance.
IValidatables should assume they are valid until
IValidatable.error(IValidationError) is called.
isValid in interface IValidatable<T>true if the object is in a valid state, false if otherwiseIValidatable.isValid()public IModel<T> getModel()
IValidatable
getModel in interface IValidatable<T>
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||