Dear Jens,

yes you are fully right. Validation is performed at the moment when 
persistence provider is called. ServiceLayerDecorator.validate() method was 
a bad choice. OK so far.
I get the ConstraintViolationException and i forward it to my 
CustomRequestFactory.

The code is similar to this:
http://cleancodematters.com/2011/05/29/improved-exceptionhandling-with-gwts-requestfactory/

Since it is an exception, the ExceptionHandler method 
createServerFailure(Throwable throwable) gets called. I can also check if 
it is a ConstraintViolationException.

So now:
How do I propagate ConstraintViolationException from my 
CustomRequestFactory correctly to the client so that 
Receiver.onConstraintViolation() is called on the client?

Thank you in advance:

Nermin



Am Donnerstag, 1. August 2013 18:09:09 UTC+2 schrieb Jens:
>
> Pre persist validation are handled by your persistence provider on the fly 
> whenever you try to persist an entity. The downside is that your 
> persistence provider will probably throw exceptions if validation fails 
> which causes RequestFactory to call Receiver.onFailure() on the client 
> because your server side service method throws an unexpected exception now.
>
> I think there is no viable solution for pre-persist validation. You could 
> probably modify RequestFactory on server side and let it catch any 
> ConstraintViolationException during the service method invocation phase and 
> then propagate them correctly to the client so that 
> Receiver.onConstraintViolation() is called on the client. To do so you 
> would need to copy RequestFactoryServlet and SimpleRequestProcessor from 
> the GWT SDK into your project and patch them to your needs.
>
> Not sure if there are other ways to solve this.
>
> -- J.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to