RequestFactory and JSR 303 validator behavior customization

205 views
Skip to first unread message

Romain BIARD

unread,
Sep 30, 2011, 9:16:40 AM9/30/11
to google-we...@googlegroups.com
Hi all,

My project has some Entities stored in Mysql and we are using Hibernate Validator as JSR 303 implementation.

My problem is that GWT ServiceLayerDecorator considers that any operations on the database need a complete validation on the objects, even delete (in my case).

Maybe it would be nice if we had the possibility to choose "FOR A GIVEN METHOD" declared in a RequestContext to skip the validation and just execute the method, bypassing the validation.
(maybe with a @ValidatorPolicy(ValidatorPolicy.SKIPPED))

Even if I'm conscious that my DB should not be invalid toward my validators,it is very embarrassing because it need a intervention directly on the DB (validators block the GWT user and even a Administrator could not repair the damages done in the DB through my app).

What do you think about this ?

Thomas Broyer

unread,
Sep 30, 2011, 2:30:08 PM9/30/11
to google-we...@googlegroups.com
You can turn validation off (or customize it) in RF using a ServiceLayerDecorator.

If you want, using the same approach, you could also implement some kind of "validate the arguments of this method before calling it" (triggered, or disabled, by an annotation on the method) but then you couldn't trigger an onConstraintViolations on the client, only an onFailure for that particular invocation.

ungarida

unread,
Oct 1, 2011, 9:29:55 AM10/1/11
to google-we...@googlegroups.com
My problem instead is the management of specific application runtime exception when I fire a request from client.
For example FileNotFound on filesystem or DuplicateKey on db... How can I send a specific application error message throw RequestFactory framework?

Thomas Broyer

unread,
Oct 1, 2011, 10:04:04 PM10/1/11
to google-we...@googlegroups.com
While not made clear anywhere in the docs, I believe RF is designed around the idea that you'll use response objects to convey the success or error status. onFailure is more about unexpected exceptions. You can use a custom ExceptionHandler though to build the ServerFailure you'll receive in onFailure.

ungarida

unread,
Oct 3, 2011, 3:50:46 AM10/3/11
to google-we...@googlegroups.com
As I wrote here http://groups.google.com/group/google-web-toolkit/browse_thread/thread/a9d5444eae6e0af0/  
it was quite clear to me that onFaillure is for the "communication channel" exception and I may use onSuccess callback.

I was not able to build a wrapper object with entity proxy and error message so do you suggest a custom ExceptionHandler with custom Exceptions with nice error messages?

Daniel Melo Brasil

unread,
May 8, 2012, 5:50:00 PM5/8/12
to google-we...@googlegroups.com
One possible way of controlling when and what will be validate is through the use of Groups (JSR 303). You can create a group and associate all validation constraints to that group.

Daniel Melo Brasil

unread,
May 8, 2012, 5:52:27 PM5/8/12
to google-we...@googlegroups.com
One possible wauy of solving this situation is throught the use of validation groups (JSR 303). You can associate your constraints to specific groups so that by default it won't be validated.


On Friday, September 30, 2011 10:16:40 AM UTC-3, Romain BIARD wrote:
On Friday, September 30, 2011 10:16:40 AM UTC-3, Romain BIARD wrote:
Reply all
Reply to author
Forward
0 new messages