myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <wikidi...@apache.org>
Subject [Myfaces Wiki] Update of "Extensions/Validator/DevDoc" by GerhardPetracek
Date Fri, 10 Apr 2009 13:34:40 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Myfaces Wiki" for change notification.

The following page has been changed by GerhardPetracek:
http://wiki.apache.org/myfaces/Extensions/Validator/DevDoc

------------------------------------------------------------------------------
  ==== comments ====
  @BeanValidation.List is the JSR 303 style for constraints
  
+ === conditional validation ===
+ 
+ example 1:
+ {{{
+ @BeanValidation(viewIds = "/form1.jsp", useGroups = User.class, conditions = "#{person.role
eq 'admin'}")
+ }}}
+ 
+ that means:[[BR]]
+ it's only validated if at least one condition returns true.
+ 
+ === model validation ===
+ it's possible to activate model validation as well (validation after the "update model values"
phase).[[BR]]
+ if activated, the last base of the bound property is validated.[[BR]]
+ in case of the example-binding[[BR]]
+ #{pageBean.pageBeanProperty.property1.property2.propertyBase.property}[[BR]]
+ the object of '''propertyBase''' gets validated per default. all you have to do is to add
the @ModelValidation.[[BR]]
+ optionally you can provide one or more custom target(s) via a conventional el-binding.[[BR]]
+ per default the validation error messages are displayed via the messages component (e.g.
h:messages). if it makes sense, you can display also these model-validation error messages
at the component which triggered the model validation process of the object. (to be correct:
the message component for the input-component which triggered the model validation.)
+ 
+ example 1:
+ {{{
+ @BeanValidation(useGroups = Address.class, modelValidation = @ModelValidation(isActive =
true))
+ }}}
+ 
+ that means:[[BR]]
+ after the field based bean-validation (jsr 303) validation of all bound properties (in the
"process validations" phase), the model is updated by jsf. afterwards model-validation for
the address group is executed.
+ 
+ example 2:
+ {{{
+ @BeanValidation.List({
+         @BeanValidation(viewIds = "/form1.jsp", useGroups = Admin.class),
+         @BeanValidation(viewIds = "/form1.jsp", useGroups = Address.class,
+                 modelValidation = @ModelValidation(isActive = true))
+ })
+ }}}
+ 
+ that means:[[BR]]
+ field based validation on page form1.jsp is performed with the admin group and model validation
for the same page is performed with the address group.
+ 
+ example 3:
+ {{{
+ @BeanValidation(useGroups = Address.class, modelValidation = @ModelValidation(isActive =
true, displayInline = true))
+ }}}
+ 
+ that means:[[BR]]
+ it's like example 1. in contrast to example 1 the validation error messages are displayed
inline (at the message component of the component which triggered the model validation)
+ 
+ example 4:
+ {{{
+ @BeanValidation(useGroups = Address.class,
+         modelValidation = @ModelValidation(isActive = true, validationTargets = "#{registrationPage.person.address}"))
+ }}}
+ 
+ that means:[[BR]]
+ instead of validating the last base (the '''propertyBase''' of the previous binding-example),
the address object of the "current" person gets validated.
+ 
- === topics to think about ===
+ === to think about ===
+ {{{
+ @BeanValidation(useGroups = Address.class, modelValidation = @ModelValidation(isActive =
true, displayInline = true,
+         message = "..."))
+ }}}
- 1) [[BR]]
- @BeanValidation(viewIds = "/form1.jsp", useGroups = [list groups], restrictGroups = [list
groups])[[BR]]
- example: to remove a group for a special property which was added at the class-level
- 
- 2) [[BR]]
- add/remove groups via annotations at action methods
  
  ----
  

Mime
View raw message