-
1. Re: errai's databinder and gwt validation
csa Nov 15, 2012 10:16 PM (in response to lewarrior22)Hi Boris,
It's not a design principle. We just haven't integrated data binding with validation yet. However, there is a workaround you should be able to use:
Unwrap the data binding proxies before passing them to the validator.
{code}
Account account = ((BindableProxy<Account>) accountBinder.getModel()).unwrap();
Validator validator = Validation.buildDefaultValidatorFactory().getValidator();
Set<ConstraintViolation<Account>> constraintViolations = validator.validate(account);
{code}
Cheers,
Christian
-
2. Re: errai's databinder and gwt validation
lewarrior22 Nov 16, 2012 5:16 AM (in response to csa)It is perfect !
{code}
//I had to cast in account again
Account account = (Account) ((BindableProxy<Account>) accountDataBinder.getModel()).unwrap();
Validator validator = Validation.buildDefaultValidatorFactory().getValidator();
Set<ConstraintViolation<Account>> constraintViolations = validator.validate(account);{code}
Thanks Christians.
-
3. Re: errai's databinder and gwt validation
holsen Oct 4, 2013 12:59 PM (in response to lewarrior22)Now that Errai 2.4 includes Errai Navigation, Errai does the work for us. However, nested objects annotated with @Valid which are used in chained data binding don't get validated properly. I think it's because their DataBinding Proxies don't get removed.
-
4. Re: errai's databinder and gwt validation
csa Oct 4, 2013 2:33 PM (in response to holsen)Hi Chris,
I am aware of that limitation when validating nested bindables with @Valid. The only clean solution I can think of is to generate our own validators (instead of using GWTs generated validators directly). However, this is quite a maintenance burden and will cause compatibility issues in the future. We were in a similar situation with our own UIBinder module.
A workaround you can use right away is to use method level annotations instead of field level annotations on your nested bindable types.
Cheers,
Christian
-
5. Re: errai's databinder and gwt validation
holsen Oct 9, 2013 6:39 AM (in response to csa)Hi Christian,
Well my workaround is to write a dedicated helper method for each object which walks through the whole objects and unwraps all sub objects. Afterwards validation works just fine. I was hoping that you were able to write a universal method which does just that.
Cheers,
Christian
-
6. Re: errai's databinder and gwt validation
csa Oct 15, 2013 10:58 AM (in response to holsen)Hi Chris,
I don't see a way to do this without touching the generated validators and we might have to bite the bullet and do this in Errai 3. I'd prefer not to because of the maintenance/compatibility issues I've described above. Maybe I am missing something though. If you can think of a generic solution that doesn't involve generating our own validators, please let us know. We happily accept contributions .
Thanks,
Christian