Bean Validation: Client vs Server

53 views
Skip to first unread message

objectuser

unread,
Oct 2, 2011, 6:53:05 PM10/2/11
to google-we...@googlegroups.com
I'm differentiating validations to be run on the client vs. the server using validation groups.

However, I have one validation for which I'd like a different implementation the client, due to the unavailability of the Pattern class there.  So on the client, I'd like to use the GWT RegExp class, while on the server, I'd like to use the JDK Pattern class.

So far, I've not figured out a way to do this.  It seems like the only place to specify the validator class is in the validatedBy property of the @Constraint annotation.

I even tried creating two different custom validation annotations, but the validation framework still seems to load the server version, and I get a runtime error due to the unavailability of the Pattern class.

Thanks for any advice.

Piro

unread,
Oct 3, 2011, 10:37:33 AM10/3/11
to Google Web Toolkit
What methods are you using with Pattern/RegExp. String.matches isn't
enough?

Thomas Broyer

unread,
Oct 3, 2011, 11:28:48 AM10/3/11
to google-we...@googlegroups.com
Why don't you use the com.google.gwt.regexp.shared.RegExp on the server too?

Otherwise, I believe using super-source you could provide a client-side-only implementation.

objectuser

unread,
Oct 3, 2011, 12:57:28 PM10/3/11
to google-we...@googlegroups.com
I thought about just using RegExp on the sever, but it just seemed wrong to rely on that on the sever.  Not sure why, since I'm pretty coupled to GWT in any case. :)

The super-source idea is interesting.  I didn't know about that feature before.  Googling it, it seems pretty interesting.

Thanks for the recommendations!  I think I'll try out the super-source idea and then fallback to using RegExp.

objectuser

unread,
Oct 3, 2011, 3:38:39 PM10/3/11
to google-we...@googlegroups.com
Yeah, String.matches only matches the entire input.  I need to see if the string contains a regular expression, as in pattern.matcher(string).find().

Also, String.matches compiles the expression every time.
Reply all
Reply to author
Forward
0 new messages