Only the default validation group is supported GWT at this time.  I have no 
good solution for using another validation group because if you throw a 
validation exception from an handler, it triggers the wrong method of the 
Receiver<T> on the client side (onServerFailure instead of on constraint 
violation)



On Tuesday, April 3, 2012 4:40:04 PM UTC-4, Romain BIARD wrote:
>
> Hi all,
>
>
> I'm writing Custom Validators (server side I mean) in order to validate an 
> entity before a persist() call (and only in this specific case).
>
> Actually my final goal is to display localized messages when users want to 
> insert a duplicate entry in my CRUD Webapp.
>
>
> To do this, i have tried to play with validation groups and validation 
> triggers. In Hibernate you can associate Custom ValidationGroup (Here  
> com.test.cis.server.validator.PreRemove 
> , com.test.cis.server.validator.PrePersist, com.test.cis.server.validator
> .PreUpdate) and validation triggers.
>
> *
> *
>
> *persistence.xml*
>
>
> <property name="javax.persistence.validation.group.pre-remove" value="
> com.test.cis.server.validator.PreRemove"/>
>
> <property name="javax.persistence.validation.group.pre-persist" value=
> "javax.validation.groups.Default,com.test.cis.server.validator.PrePersist"
> />
>
> <property name="javax.persistence.validation.group.pre-update" value=
> "javax.validation.groups.Default,com.test.cis.server.validator.PreUpdate"
> />
>
>
> On my bean, I've put my custom annotation with 
> com.test.cis.server.validator.PrePersist.class as validation group.
>
>
> @MyConstraint(groups=com.test.cis.server.validator.PrePersist.class)
>
>
> So my problem turns around the GWT validation with requestfactory : the 
> validation is done *before* (so the validation will not execute my custom 
> validator at this time ) the call to persist (which will trigger 
> myConstraint validator) so GWT can't handle Constraint Violation exception 
> that occurs during a method call(i.e during method execution). In this 
> case, the exception is catch by the standard ExceptionHandling mechanism 
> and every informations / Localized messages are lost.
>
>
> javax.validation.ConstraintViolationException: validation failed for 
> classes [com.test.domain.entity.CatalogueEntity] during persist time for 
> groups [javax.validation.groups.Default, 
> com.test.cis.server.validator.PrePersist, ]
>
>
> Have you ever been in this case ? Another solution ?
>
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-web-toolkit/-/fP_Sv_g8V-4J.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to