public class FormBeanValidator extends AbstractValidator
AbstractValidator.addInvalidMessage(ValidationContext, String, String)
.
To use this class, you have to add @validator('formBeanValidator',prefix='p_')
or @validator('org.zkoss.zkoss.bind.FormBeanValidator',prefix='p_')
to the form-binding,
where prefix
is an argument of the message name(prefix+property
) for a property.
Because of the message name is shared between same ValidationMessages
, that is same Binder
,
you have to provide a unique prefix for every FormBeanValidator in same binder.
Example
<grid width="600px" form="@id('fx') @load(vm.user) @save(vm.user,after='save') @validator('formBeanValidator',prefix='p_')">
<textbox value="@bind(fx.firstName)"/>
<label value="@load(vmsgs['p_firstName'])"/>
</grid>
Constructor and Description |
---|
FormBeanValidator() |
Modifier and Type | Method and Description |
---|---|
protected java.lang.Class |
getBeanClass(ValidationContext ctx,
java.lang.Object base)
Get the bean class of the base object.
|
protected javax.validation.Validator |
getValidator() |
protected void |
handleConstraintViolation(ValidationContext ctx,
java.lang.String key,
java.util.Set<javax.validation.ConstraintViolation<?>> violations)
Handle hibernate ConstraintViolation.
|
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)
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)
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 void handleConstraintViolation(ValidationContext ctx, java.lang.String key, java.util.Set<javax.validation.ConstraintViolation<?>> violations)
ctx
- key
- the key of messageviolations
- protected java.lang.Class getBeanClass(ValidationContext ctx, java.lang.Object base)
ctx
- the validation contextbase
- the base objectpublic void validate(ValidationContext ctx)
Copyright © 2005-2011 Potix Corporation. All Rights Reserved.