Monday, January 7, 2013

Re: How to validate TextBox fields?



On Monday, January 7, 2013 4:50:03 PM UTC+1, Nick Chalko wrote:



On Mon, Jan 7, 2013 at 7:42 AM, Thomas Broyer <t.br...@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.




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 propertyName of the class beanType would the property value be value

ConstraintViolation objects return null for ConstraintViolation#getRootBean() and ConstraintViolation#getLeafBean()


Ooh, great! Thanks for the tip Nick.

--
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/-/RPL7MVRxYjgJ.
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