|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sf.easyweb4j.model.Model
public abstract class Model
Super class to be extended by all application's models. It provides various methods to simplify creating a well-encapsulated domain model.
Constructor Summary | |
---|---|
Model()
|
Method Summary | |
---|---|
void |
addError(String property,
String errorKey)
Adds an error key for the specified property. |
void |
clearErrors()
Clears all the errors on the model's properties. |
Map<String,ErrorDetail> |
getErrors()
Returns a map of all errors on the properties of the model with the name of the properties as the key. |
boolean |
hasErrorOn(String property)
Determines whether there is any error in the value of the property with the given name in the model. |
boolean |
isValid()
Determines whether there are any errors present in the values of the model's properties. |
protected void |
validate()
This method may be overridden by applications' models to validate the state of the model. |
protected void |
validateRequired(String property,
Collection<?> value)
Checks if the field isn't null and size of the collection is greater than zero. |
protected void |
validateRequired(String property,
Object value)
Checks if the field isn't null. |
protected void |
validateRequired(String property,
String value)
Checks if the field isn't null and length of the field is greater than zero after trimming white spaces. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Model()
Method Detail |
---|
public void addError(String property, String errorKey)
property
- The property for which the error key is to be added.errorKey
- The error message key to be added.public void clearErrors()
public boolean hasErrorOn(String property)
property
- The property whose errors are to be checked.
public boolean isValid()
public Map<String,ErrorDetail> getErrors()
protected void validate()
protected void validateRequired(String property, Object value)
property + ".required"
.
property
- The name of the property to be validated.value
- The current value of the property.protected void validateRequired(String property, String value)
property + ".required"
.
property
- The name of the property to be validated.value
- The current value of the property.protected void validateRequired(String property, Collection<?> value)
property + ".required"
.
property
- The name of the property to be validated.value
- The current value of the property.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |