-->
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.  [ 4 posts ] 
Author Message
 Post subject: pattern for in-place validation feedback in form
PostPosted: Wed May 13, 2009 3:56 pm 
Newbie

Joined: Wed Mar 02, 2005 1:28 pm
Posts: 18
The BV spec looks good and it is easy to see how a List<ConstraintViolation> f ex could be rendered in a message frame at the top of a web page.

Looking at a little more challenging scenario; when the validation feedback is desired together with / beside the respective item or input field, how would that best be designed with BV? A naive approach would be to make validation status part of the validated object or attribute so it is easily available at the point where it is rendered, but that doesn't feel right...

Does anyone have suggestions for the Right Way (tm) to do this?


Top
 Profile  
 
 Post subject: Re: pattern for in-place validation feedback in form
PostPosted: Mon Jun 22, 2009 1:45 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
I think validateProperty is actually a very nice approach. That or the ability to filter ConstraintViolations by propertyPath

_________________
Emmanuel


Top
 Profile  
 
 Post subject: Re: pattern for in-place validation feedback in form
PostPosted: Mon Jun 22, 2009 2:51 pm 
Newbie

Joined: Wed Mar 02, 2005 1:28 pm
Posts: 18
emmanuel wrote:
I think validateProperty is actually a very nice approach. That or the ability to filter ConstraintViolations by propertyPath

I want to run the validation in the presentation logic, and not in the view, so if using validateProperty() I would have to keep the validation result for each property in a separate list to hand over to the view. I guess that would be kind of messy unless storing the violations inside the same view DTO as the data, ie:
Code:
class MyViewDto {
  PhoneNumber phone;
  List<ConstraintViolation> phoneViolations;
  ...
}
-or-
class MyViewDto {
  PhoneNumberAndViolations phone;
  ...
}

but I get a little awkward feeling from mixing data and validation results. But maybe it's ok as it is view data?
Maybe the filtering solution is cleaner, imagining that the view should get a ConstraintViolation list separately from MyViewDto and then have matching property names specified inside the view code for filtering...
Thoughts?


Top
 Profile  
 
 Post subject: Re: pattern for in-place validation feedback in form
PostPosted: Mon Jun 22, 2009 3:30 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
That's how it's done in JSF AFAIK:
a view component hosts:
- the value
- the validators

each validator can raise errors on its hosting component.

_________________
Emmanuel


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