|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.wicket.validation.Validatable
public class Validatable
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(java.lang.Object value)
Constructor. |
|
| Method Summary | |
|---|---|
void |
error(IValidationError error)
Reports an error against this IValidatable's value. |
java.util.List |
getErrors()
Retrieves an unmodifiable list of any errors reported against this IValidatable
instance. |
java.lang.Object |
getValue()
Retrieves the value to be validated. |
boolean |
isValid()
Queries the current state of this IValidatable instance. |
void |
setValue(java.lang.Object 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(java.lang.Object value)
value - The value that will be tested| Method Detail |
|---|
public void setValue(java.lang.Object value)
getValue().
value - the value objectpublic java.lang.Object getValue()
IValidatable
getValue in interface IValidatableIValidatable.getValue()public void error(IValidationError error)
IValidatableIValidatable's value. Multiple errors can be
reported by calling this method multiple times.
error in interface IValidatableerror - an IValidationError to be reportedIValidatable.error(IValidationError)public java.util.List getErrors()
IValidatable
instance.
public boolean isValid()
IValidatableIValidatable instance.
IValidatables should assume they are valid until
IValidatable.error(IValidationError) is called.
isValid in interface IValidatabletrue if the object is in a valid state, false if
otherwiseIValidatable.isValid()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||