com.missiondata.oss.lakeshore
Class Validator
java.lang.Object
com.missiondata.oss.lakeshore.Validator
- Direct Known Subclasses:
- RequiredField
- public abstract class Validator
- extends java.lang.Object
'Validate' a filed on second use
First attempt at pulling validation up into the framework. Time will tell if it will stay and grow...
On example use of this is
In the render:
final boolean valid = validator.isValid();
if( !valid) cssClass("error");
tableRow(new F(){public void f(){
cssClass("label");
tableData(label);
cssClass("value");
tableData(new F(){public void f(){
textInputOn(model, property);
if(!valid)
{
cssClass("error");
span(validator.getMessage());
}
}});
}});
In the submit handler
if(firstName.validate() & lastName.validate() & emailAddress.validate() & password.validate())
Note: Notice the aritmetic & instead of the boolean &&. This will ensure all validations are run
Method Summary |
abstract java.lang.String |
getMessage()
|
boolean |
isValid()
Get the validation 'state'. |
protected abstract boolean |
isValidImpl()
|
boolean |
validate()
Execute the validation. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Validator
public Validator()
validate
public boolean validate()
- Execute the validation.
- Returns:
isValid
public boolean isValid()
- Get the validation 'state'. This will also flip the validation state back to true
- Returns:
isValidImpl
protected abstract boolean isValidImpl()
getMessage
public abstract java.lang.String getMessage()