On Mon, Jan 7, 2013 at 7:42 AM, Thomas Broyer <t.bro...@gmail.com> wrote:
> > > On Monday, January 7, 2013 3:45:53 PM UTC+1, membersound wrote: >> >> Yes I know this side. But it still does not tell me: >> - how to validate the name before creating the person object (which I'm >> looking for in terms of numbers like int age; There I'd first like the >> validator to catch if it's a valid age before creating the person object) > > > If you want to use the annotations that are on your Person fields, then > you have to create a Person object. > Technically, I believe you could generate code, the generator reading the > annotations and producing code that will be able to validate data before > creating the Person object, but there's no such things in GWT proper. > That being said, creating a Person object shouldn't be that expensive that > you want to avoid it a all costs. > > http://docs.oracle.com/javaee/6/api/javax/validation/Validator.html#validateValue(java.lang.Class, java.lang.String, java.lang.Object, java.lang.Class...) validateValue <T> java.util.Set<ConstraintViolation <http://docs.oracle.com/javaee/6/api/javax/validation/ConstraintViolation.html><T>> *validateValue*(java.lang.Class<T> beanType, java.lang.String propertyName, java.lang.Object value, java.lang.Class<?>... groups) Validates all constraints placed on the property named propertyName of the class beanType would the property value be value ConstraintViolation objects return null for ConstraintViolation#getRootBean() and ConstraintViolation#getLeafBean() *Parameters:*beanType - the bean type propertyName - property to validate value - property value to validategroups - group or list of groups targeted for validation (default to Default<http://docs.oracle.com/javaee/6/api/javax/validation/groups/Default.html> ) *Returns:*constraint violations or an empty Set if none*Throws:* IllegalArgumentException - if beanType is null, if propertyName null, empty or not a valid object property or if null is passed to the varargs groups ValidationException - if a non recoverable error happens during the validation process ------------------------------ -- Nick Chalko | Software Engineer | ncha...@google.com | :-) Generate your java flags for easier testing. go/java_flags -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. 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.