You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by Yaocl <ch...@gmail.com> on 2012/09/14 10:06:55 UTC
How to make CODI BV module work
Hi
I can't figure out how to make CODI Bean Validation modules work. I
have a custom constraint require query db.
I have put all CODI jar files in my WEB-INF/lib folder. But @Inject
not work in my custom validator.
My java server is TomEE+ 1.1 snapshot. I tried to debug it, Both JSF
and JPA using default Validator Factory.
Can someone give me a example of using CODI BV module?
--
YaoCL
Re: How to make CODI BV module work
Posted by Gerhard Petracek <ge...@gmail.com>.
short addition @validator-factory:
for sure you can use it as well, but not directly as default implementation.
(you would have to create a small adapter for it which resolves the
@Advanced validator-factory -> delegate to it).
regards,
gerhard
http://www.irian.at
Your JSF/JavaEE powerhouse -
JavaEE Consulting, Development and
Courses in English and German
Professional Support for Apache MyFaces
2012/9/15 Gerhard Petracek <ge...@gmail.com>
> hi yaocl,
>
> you also have to inject and use an @Advanced javax.validation.Validator.
> please have a look at [1].
>
> regards,
> gerhard
>
> [1] https://cwiki.apache.org/confluence/display/EXTCDI/BV+Usage
>
> http://www.irian.at
>
> Your JSF/JavaEE powerhouse -
> JavaEE Consulting, Development and
> Courses in English and German
>
> Professional Support for Apache MyFaces
>
>
>
>
> 2012/9/14 YaoCL <ch...@gmail.com>
>
>> Hi
>>
>> I think the JSF and JPA must use InjectableValidatorFactory to support
>> CDIAwareValidator.
>> But put the CODI jars into WEB-INF/lib not make the JSF and JPA use
>> InjectableValidatorFactory,
>> They still use ApacheValidatorFactory.
>>
>> If I @Inject ValidatorFactory into ManageBean I can get
>> InjectableValidatorFactory
>>
>> @Named
>> @RequestScope
>> public class PageController {
>> @Inject
>> @Advanced
>> ValidatorFactory validatorFactory;
>>
>> }
>>
>> How to replace the default ValidatorFactory?
>>
>> Regards
>> YaoCL
>>
>> 在 2012-9-14,下午4:26,Yaocl <ch...@gmail.com> 写道:
>>
>> > Hi
>> >
>> > I have @Advanced on my validator. Is there extra config required for
>> CODI?
>> > I only copied the jars into WEB-INF/lib folder.
>> >
>> >
>> > @ApplicationScoped
>> > @Advanced
>> > public class NameUniqueValidator implements
>> > ConstraintValidator<NameUnique, String>, Serializable {
>> >
>> > /**
>> > *
>> > */
>> > private static final long serialVersionUID = 1L;
>> > @Inject
>> > private UserService service;
>> >
>> > @Override
>> > public void initialize(NameUnique arg0) {
>> > }
>> >
>> > @Override
>> > public boolean isValid(String name, ConstraintValidatorContext
>> context) {
>> > return service.isNameValid(name);
>> > }
>> > }
>> >
>> > Regards,
>> > YaoCL
>> >
>> > On Fri, Sep 14, 2012 at 4:18 PM, Thomas Andraschko <zo...@gmail.com>
>> wrote:
>> >> Hi,
>> >>
>> >> did you try @Advanced on your validator?
>> >> This is required if you did not deactivate it via config.
>> >>
>> >> Regards,
>> >> Thomas
>> >>
>> >>
>> >> 2012/9/14 Yaocl <ch...@gmail.com>
>> >>>
>> >>> Hi
>> >>>
>> >>> I can't figure out how to make CODI Bean Validation modules work. I
>> >>> have a custom constraint require query db.
>> >>> I have put all CODI jar files in my WEB-INF/lib folder. But @Inject
>> >>> not work in my custom validator.
>> >>>
>> >>> My java server is TomEE+ 1.1 snapshot. I tried to debug it, Both JSF
>> >>> and JPA using default Validator Factory.
>> >>>
>> >>> Can someone give me a example of using CODI BV module?
>> >>>
>> >>>
>> >>> --
>> >>> YaoCL
>> >>
>> >>
>>
>>
>
Re: How to make CODI BV module work
Posted by Yaocl <ch...@gmail.com>.
Hi gehard
Inject a javax.validation.Validator and call it manually works.
Thank you.
Combination of CODI and ExtVal not works with BVal-0.4 but it works
with BVal-0.2.
I created a bug report at https://issues.apache.org/jira/browse/BVAL-111
Regards,
YaoCL
On Sat, Sep 15, 2012 at 4:50 PM, Gerhard Petracek
<ge...@gmail.com> wrote:
> hi yaocl,
>
> you also have to inject and use an @Advanced javax.validation.Validator.
> please have a look at [1].
>
> regards,
> gerhard
>
> [1] https://cwiki.apache.org/confluence/display/EXTCDI/BV+Usage
>
> http://www.irian.at
>
> Your JSF/JavaEE powerhouse -
> JavaEE Consulting, Development and
> Courses in English and German
>
> Professional Support for Apache MyFaces
>
>
>
>
> 2012/9/14 YaoCL <ch...@gmail.com>
>>
>> Hi
>>
>> I think the JSF and JPA must use InjectableValidatorFactory to support
>> CDIAwareValidator.
>> But put the CODI jars into WEB-INF/lib not make the JSF and JPA use
>> InjectableValidatorFactory,
>> They still use ApacheValidatorFactory.
>>
>> If I @Inject ValidatorFactory into ManageBean I can get
>> InjectableValidatorFactory
>>
>> @Named
>> @RequestScope
>> public class PageController {
>> @Inject
>> @Advanced
>> ValidatorFactory validatorFactory;
>>
>> }
>>
>> How to replace the default ValidatorFactory?
>>
>> Regards
>> YaoCL
>>
>> 在 2012-9-14,下午4:26,Yaocl <ch...@gmail.com> 写道:
>>
>> > Hi
>> >
>> > I have @Advanced on my validator. Is there extra config required for
>> > CODI?
>> > I only copied the jars into WEB-INF/lib folder.
>> >
>> >
>> > @ApplicationScoped
>> > @Advanced
>> > public class NameUniqueValidator implements
>> > ConstraintValidator<NameUnique, String>, Serializable {
>> >
>> > /**
>> > *
>> > */
>> > private static final long serialVersionUID = 1L;
>> > @Inject
>> > private UserService service;
>> >
>> > @Override
>> > public void initialize(NameUnique arg0) {
>> > }
>> >
>> > @Override
>> > public boolean isValid(String name, ConstraintValidatorContext
>> > context) {
>> > return service.isNameValid(name);
>> > }
>> > }
>> >
>> > Regards,
>> > YaoCL
>> >
>> > On Fri, Sep 14, 2012 at 4:18 PM, Thomas Andraschko <zo...@gmail.com>
>> > wrote:
>> >> Hi,
>> >>
>> >> did you try @Advanced on your validator?
>> >> This is required if you did not deactivate it via config.
>> >>
>> >> Regards,
>> >> Thomas
>> >>
>> >>
>> >> 2012/9/14 Yaocl <ch...@gmail.com>
>> >>>
>> >>> Hi
>> >>>
>> >>> I can't figure out how to make CODI Bean Validation modules work. I
>> >>> have a custom constraint require query db.
>> >>> I have put all CODI jar files in my WEB-INF/lib folder. But @Inject
>> >>> not work in my custom validator.
>> >>>
>> >>> My java server is TomEE+ 1.1 snapshot. I tried to debug it, Both JSF
>> >>> and JPA using default Validator Factory.
>> >>>
>> >>> Can someone give me a example of using CODI BV module?
>> >>>
>> >>>
>> >>> --
>> >>> YaoCL
>> >>
>> >>
>>
>
Re: How to make CODI BV module work
Posted by Gerhard Petracek <ge...@gmail.com>.
hi yaocl,
you also have to inject and use an @Advanced javax.validation.Validator.
please have a look at [1].
regards,
gerhard
[1] https://cwiki.apache.org/confluence/display/EXTCDI/BV+Usage
http://www.irian.at
Your JSF/JavaEE powerhouse -
JavaEE Consulting, Development and
Courses in English and German
Professional Support for Apache MyFaces
2012/9/14 YaoCL <ch...@gmail.com>
> Hi
>
> I think the JSF and JPA must use InjectableValidatorFactory to support
> CDIAwareValidator.
> But put the CODI jars into WEB-INF/lib not make the JSF and JPA use
> InjectableValidatorFactory,
> They still use ApacheValidatorFactory.
>
> If I @Inject ValidatorFactory into ManageBean I can get
> InjectableValidatorFactory
>
> @Named
> @RequestScope
> public class PageController {
> @Inject
> @Advanced
> ValidatorFactory validatorFactory;
>
> }
>
> How to replace the default ValidatorFactory?
>
> Regards
> YaoCL
>
> 在 2012-9-14,下午4:26,Yaocl <ch...@gmail.com> 写道:
>
> > Hi
> >
> > I have @Advanced on my validator. Is there extra config required for
> CODI?
> > I only copied the jars into WEB-INF/lib folder.
> >
> >
> > @ApplicationScoped
> > @Advanced
> > public class NameUniqueValidator implements
> > ConstraintValidator<NameUnique, String>, Serializable {
> >
> > /**
> > *
> > */
> > private static final long serialVersionUID = 1L;
> > @Inject
> > private UserService service;
> >
> > @Override
> > public void initialize(NameUnique arg0) {
> > }
> >
> > @Override
> > public boolean isValid(String name, ConstraintValidatorContext
> context) {
> > return service.isNameValid(name);
> > }
> > }
> >
> > Regards,
> > YaoCL
> >
> > On Fri, Sep 14, 2012 at 4:18 PM, Thomas Andraschko <zo...@gmail.com>
> wrote:
> >> Hi,
> >>
> >> did you try @Advanced on your validator?
> >> This is required if you did not deactivate it via config.
> >>
> >> Regards,
> >> Thomas
> >>
> >>
> >> 2012/9/14 Yaocl <ch...@gmail.com>
> >>>
> >>> Hi
> >>>
> >>> I can't figure out how to make CODI Bean Validation modules work. I
> >>> have a custom constraint require query db.
> >>> I have put all CODI jar files in my WEB-INF/lib folder. But @Inject
> >>> not work in my custom validator.
> >>>
> >>> My java server is TomEE+ 1.1 snapshot. I tried to debug it, Both JSF
> >>> and JPA using default Validator Factory.
> >>>
> >>> Can someone give me a example of using CODI BV module?
> >>>
> >>>
> >>> --
> >>> YaoCL
> >>
> >>
>
>
Re: How to make CODI BV module work
Posted by YaoCL <ch...@gmail.com>.
Hi
I think the JSF and JPA must use InjectableValidatorFactory to support CDIAwareValidator.
But put the CODI jars into WEB-INF/lib not make the JSF and JPA use InjectableValidatorFactory,
They still use ApacheValidatorFactory.
If I @Inject ValidatorFactory into ManageBean I can get InjectableValidatorFactory
@Named
@RequestScope
public class PageController {
@Inject
@Advanced
ValidatorFactory validatorFactory;
}
How to replace the default ValidatorFactory?
Regards
YaoCL
在 2012-9-14,下午4:26,Yaocl <ch...@gmail.com> 写道:
> Hi
>
> I have @Advanced on my validator. Is there extra config required for CODI?
> I only copied the jars into WEB-INF/lib folder.
>
>
> @ApplicationScoped
> @Advanced
> public class NameUniqueValidator implements
> ConstraintValidator<NameUnique, String>, Serializable {
>
> /**
> *
> */
> private static final long serialVersionUID = 1L;
> @Inject
> private UserService service;
>
> @Override
> public void initialize(NameUnique arg0) {
> }
>
> @Override
> public boolean isValid(String name, ConstraintValidatorContext context) {
> return service.isNameValid(name);
> }
> }
>
> Regards,
> YaoCL
>
> On Fri, Sep 14, 2012 at 4:18 PM, Thomas Andraschko <zo...@gmail.com> wrote:
>> Hi,
>>
>> did you try @Advanced on your validator?
>> This is required if you did not deactivate it via config.
>>
>> Regards,
>> Thomas
>>
>>
>> 2012/9/14 Yaocl <ch...@gmail.com>
>>>
>>> Hi
>>>
>>> I can't figure out how to make CODI Bean Validation modules work. I
>>> have a custom constraint require query db.
>>> I have put all CODI jar files in my WEB-INF/lib folder. But @Inject
>>> not work in my custom validator.
>>>
>>> My java server is TomEE+ 1.1 snapshot. I tried to debug it, Both JSF
>>> and JPA using default Validator Factory.
>>>
>>> Can someone give me a example of using CODI BV module?
>>>
>>>
>>> --
>>> YaoCL
>>
>>
Re: How to make CODI BV module work
Posted by Yaocl <ch...@gmail.com>.
Hi
I have @Advanced on my validator. Is there extra config required for CODI?
I only copied the jars into WEB-INF/lib folder.
@ApplicationScoped
@Advanced
public class NameUniqueValidator implements
ConstraintValidator<NameUnique, String>, Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
@Inject
private UserService service;
@Override
public void initialize(NameUnique arg0) {
}
@Override
public boolean isValid(String name, ConstraintValidatorContext context) {
return service.isNameValid(name);
}
}
Regards,
YaoCL
On Fri, Sep 14, 2012 at 4:18 PM, Thomas Andraschko <zo...@gmail.com> wrote:
> Hi,
>
> did you try @Advanced on your validator?
> This is required if you did not deactivate it via config.
>
> Regards,
> Thomas
>
>
> 2012/9/14 Yaocl <ch...@gmail.com>
>>
>> Hi
>>
>> I can't figure out how to make CODI Bean Validation modules work. I
>> have a custom constraint require query db.
>> I have put all CODI jar files in my WEB-INF/lib folder. But @Inject
>> not work in my custom validator.
>>
>> My java server is TomEE+ 1.1 snapshot. I tried to debug it, Both JSF
>> and JPA using default Validator Factory.
>>
>> Can someone give me a example of using CODI BV module?
>>
>>
>> --
>> YaoCL
>
>
Re: How to make CODI BV module work
Posted by Thomas Andraschko <zo...@gmail.com>.
Hi,
did you try @Advanced on your validator?
This is required if you did not deactivate it via config.
Regards,
Thomas
2012/9/14 Yaocl <ch...@gmail.com>
> Hi
>
> I can't figure out how to make CODI Bean Validation modules work. I
> have a custom constraint require query db.
> I have put all CODI jar files in my WEB-INF/lib folder. But @Inject
> not work in my custom validator.
>
> My java server is TomEE+ 1.1 snapshot. I tried to debug it, Both JSF
> and JPA using default Validator Factory.
>
> Can someone give me a example of using CODI BV module?
>
>
> --
> YaoCL
>