myfaces-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rudy De Busscher <>
Subject [Extval] BeanAware constraint validators for Model Validation beanValidation
Date Sat, 06 Mar 2010 19:48:49 GMT
[ExtVal] BeanAware constraint validators for Model Validation beanValidation


The Constraint Validator for BeanValidation constraints on properties can be
defined in a context repository. The *
BeanValidationModuleValidationInterceptorInternals.validate* method makes
use of code that checks if a bean is defined in a context that can be used.

The *ModelValidationPhaseListener* makes use of a slightly different aproach
which leads to the fact that no beans could be used.

 A small change to the ModelValidationPhaseListener.validateTarget method
solves this problem.

I haven't tested the fix extensively but with my small test, I was able to
use a bean for the constraint validator defined on a class.


        return ExtValBeanValidationContext.getCurrentInstance()
>                 .getValidatorFactory().usingContext()
> .messageInterpolator(ExtValBeanValidationContext.getCurrentInstance().getMessageInterpolator())
>                 .getValidator()
>                 .validate(validationTarget, groups);

should become

        ValidatorFactory validatorFactory =
> ExtValBeanValidationContext.getCurrentInstance().getValidatorFactory();
>         return validatorFactory
>                 .usingContext()
> .messageInterpolator(ExtValBeanValidationContext.getCurrentInstance().getMessageInterpolator())
> .constraintValidatorFactory(validatorFactory.getConstraintValidatorFactory())
> .traversableResolver(validatorFactory.getTraversableResolver())
>                 .getValidator()
>                 .validate(validationTarget, groups);

See EXTVAL-86 for the patch.

Include it in the x.x.3 release ?


View raw message