|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.zkoss.bind.validator.AbstractValidator org.zkoss.bind.validator.BeanValidator
public class BeanValidator
A JSR 303 compatible validator for a property-binding.
Notice : Before use this validator, you have to configure your environment (depends on the implementation you chosen). Here is a article Integrate ZK with JSR 303: Bean Validation talks about how to set up JSR 303 in ZK with Hibernate implementation. It validates a single propertie of a bean and sets the invalid message byAbstractValidator.addInvalidMessage(ValidationContext, String)
.
To use this class, you have to add @validator('beanValidator')
or @validator('org.zkoss.bind.validator.BeanValidator')
to the property-binding
Example
<grid width="600px">
<textbox id="tb" value="@bind(vm.person.firstName) @validator('beanValidator')"/>
<label value="@load(vmsgs[tb])"/>
</grid>
Note
It doesn't supports to validate a property of a form which properties are load from a bean,
if you want to validate the form property of the bean, you could use org.zkoss.zkmax.bind.BeanValodator
Constructor Summary | |
---|---|
BeanValidator()
|
Method Summary | |
---|---|
protected java.lang.Object[] |
getValidationInfo(ValidationContext ctx,
java.lang.Object base,
java.lang.String property)
Get the bean class of the base object and property to validate. |
protected javax.validation.Validator |
getValidator()
|
protected void |
handleConstraintViolation(ValidationContext ctx,
java.util.Set<javax.validation.ConstraintViolation<?>> violations)
Handle hibernate ConstraintViolation. by default, it add to invalid messages. |
protected void |
sort(java.util.List<javax.validation.ConstraintViolation<?>> viloations)
Sort the viloations, make multiple violation order more predictable. |
protected java.util.Set<javax.validation.ConstraintViolation<?>> |
validate(java.lang.Class clz,
java.lang.String property,
java.lang.Object value)
Validate the value |
void |
validate(ValidationContext ctx)
|
Methods inherited from class org.zkoss.bind.validator.AbstractValidator |
---|
addInvalidMessage, addInvalidMessage, addInvalidMessages, addInvalidMessages |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public BeanValidator()
Method Detail |
---|
protected javax.validation.Validator getValidator()
protected java.util.Set<javax.validation.ConstraintViolation<?>> validate(java.lang.Class clz, java.lang.String property, java.lang.Object value)
clz
- the class of beanproperty
- the property of beanvalue
- the value to be validated.
protected void sort(java.util.List<javax.validation.ConstraintViolation<?>> viloations)
viloations
- protected java.lang.Object[] getValidationInfo(ValidationContext ctx, java.lang.Object base, java.lang.String property)
ctx
- the validation contextbase
- the base objectproperty
- the property to validate
protected void handleConstraintViolation(ValidationContext ctx, java.util.Set<javax.validation.ConstraintViolation<?>> violations)
ctx
- violations
- public void validate(ValidationContext ctx)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |