-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: [validator] How to get field-level validation for custom UI?
PostPosted: Wed Feb 26, 2014 10:12 am 
Regular
Regular

Joined: Fri Jul 30, 2004 4:02 pm
Posts: 50
Hi all,
I'm having a hard time finding a good approach/practice around using Hibernate/JPA validators with thirdparty UI frameworks.

The shortcut question is, how can you get/interrogate what validations are available on each field/property?

The long question is if you have a java/javascript framework that is custom, is there a way to pull/leverage those for client-side validation prior to submission?

thanks!
-D


Top
 Profile  
 
 Post subject: Re: [validator] How to get field-level validation for custom UI?
PostPosted: Thu Feb 27, 2014 3:48 am 
Hibernate Team
Hibernate Team

Joined: Sat Jan 24, 2009 12:46 pm
Posts: 388
Hi,

Java-based UI frameworks typically use javax.validation.Validator#validateValue() which evaluates validity of a given property value before putting it into the actual data model.

If you need to expose constraint information to JavaScript clients, you can use the metadata API (https://docs.jboss.org/hibernate/stable/validator/reference/en-US/html_single/#validator-metadata-api) which provides information about all the constraints of given types or properties. Based on that, you could implement a JS library which performs all the validations on the client side (maybe such a library even already exists?). One challenge would be custom constraints with custom validator implementations. In most cases it may be sufficient to provide a fixed set of corresponding JS implementations. Or you define a way of tagging certain constraint types as not to be run on the client side.

Hth,

--Gunnar

_________________
Visit my blog at http://musingsofaprogrammingaddict.blogspot.com/


Top
 Profile  
 
 Post subject: Re: [validator] How to get field-level validation for custom UI?
PostPosted: Thu Feb 27, 2014 3:32 pm 
Regular
Regular

Joined: Fri Jul 30, 2004 4:02 pm
Posts: 50
Thanks Gunnar, the reference to the validation metadata API got me going the right direction!

-D


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.