[hibernate-issues] [Hibernate-JIRA] Commented: (BVAL-214) Ability to validate an object and a list of changes

Gunnar Morling (JIRA) noreply at atlassian.com
Mon Sep 26 17:02:35 EDT 2011


    [ http://opensource.atlassian.com/projects/hibernate/browse/BVAL-214?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=43703#comment-43703 ] 

Gunnar Morling commented on BVAL-214:
-------------------------------------

Must have. Not being able to use class-level constraints with JSF is an issue I think many people are missing.

> Ability to validate an object and a list of changes
> ---------------------------------------------------
>
>                 Key: BVAL-214
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/BVAL-214
>             Project: Bean Validation
>          Issue Type: Improvement
>            Reporter: Emmanuel Bernard
>
> Pass a list of changes applied to an object graph and validate the object graph had the change been applied.
> This is useful for presentation layers like JSF for cross field validations for example.
> There are several possibilities to implement that:
> 1. pass in a Map<String,Object> with the list of changed properties
> {code}validator.validateObject(Object model,Map<String,Object> newValues, Class ...profile){code}
> 2. pass in a set of more typesafe changedset but essentially the same as 1.
> {code}changeSet.change("property", value).change("property2", null).remove("collection", index);
> validator.validateObject(Object model,ChangeSet changeSet, Class ...profile){code}
> 3. pass a proxy of the object and apply changes to the proxy. One of the benefits of this approach is that it is transparent to the validator API. The drawback is that the object must be proxyable
> {code}User proxiedUser = proxyfier.proxy(user);
> proxiedUser.setName("Emmanuel");
> proxiedUser.getAddresses().add(address);
> validator.validateObject(Object proxiedUser, Class ...profile){code}
> More info from Alex
> {code} Client side validation already implemented in coming RichFaces 4.0 release, that's not a subject for bean validation. From the JSF side, the cool feature would be object validation that doesn't touch model itself. Currently, we can only validate a single bean attribute aganist new value, that doesn't allow. In richfaces, I do make a 'clone' of target object, update it with new values and perform validation on the cloned object. Would be nice to have something like: validator.validateObject(Object model,Map<String,Object> newValues, Class ...profile) that does a similar work.{code}

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list