-->
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.  [ 2 posts ] 
Author Message
 Post subject: Adding violations from Validator to HTML form
PostPosted: Thu Jul 22, 2010 8:00 am 
Newbie

Joined: Mon Sep 24, 2007 9:53 am
Posts: 3
Let's say you validate your Car object with javax.validation.Validator in Hibernate Validator, and you get constraint violations for several fields in Car. A user has tried to submit the Car in an HTML form, and therefore these violations should be displayed to the user as messages associated with the relevant input fields, say "The car's weight can not be 0 kg" would be a tooltip to the field 'weight', which could also be coloured red.

If the member variable that was violated happened to be called weight in the Java code, it wouldn't be a problem to find the correct input field to attach the message to. Does anyone have a good strategy for making sure that the correct field names are used in forms, without using reflection? So that, for instance, an input element for a car's weight always has <input name="weight">? Is it possible to annotate a member with a string and then use that string as the name attribute for the input tag?

Brgds Trond


Top
 Profile  
 
 Post subject: Re: Adding violations from Validator to HTML form
PostPosted: Fri Jul 23, 2010 5:07 am 
Newbie

Joined: Mon Sep 24, 2007 9:53 am
Posts: 3
So, what are my options here? JSF, Struts, Devsphere, GWT? Could I make the mapping from scratch, by using Java annotations?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.