On Mon, Jan 7, 2013 at 7:42 AM, Thomas Broyer <t.broyer@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<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
propertyNameof the classbeanTypewould the property value bevalueConstraintViolationobjects return null forConstraintViolation#getRootBean()andConstraintViolation#getLeafBean() - Parameters:
beanType- the bean typepropertyName- property to validatevalue- property value to validategroups- group or list of groups targeted for validation (default toDefault)- Returns:
- constraint violations or an empty Set if none
- Throws:
IllegalArgumentException- ifbeanTypeis null, ifpropertyNamenull, empty or not a valid object property or if null is passed to the varargs groupsValidationException- if a non recoverable error happens during the validation process
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
No comments:
Post a Comment