public class BeanValidator extends AbstractValidator
AbstractValidator.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 and Description |
---|
BeanValidator() |
Modifier and Type | Method and Description |
---|---|
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 violations, 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,
java.lang.Class<?>[] groups)
Validate the value
|
void |
validate(ValidationContext ctx) |
addInvalidMessage, addInvalidMessage, addInvalidMessages, addInvalidMessages
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, java.lang.Class<?>[] groups)
clz
- the class of beanproperty
- the property of beanvalue
- the value to be validated.groups
- the validation groups (since 8.0.0)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 validateprotected void handleConstraintViolation(ValidationContext ctx, java.util.Set<javax.validation.ConstraintViolation<?>> violations)
ctx
- violations
- public void validate(ValidationContext ctx)
Copyright © 2005-2011 Potix Corporation. All Rights Reserved.