JSF in der Praxis
24.03.2010    DI (FH) Gerhard Petracek / MyFaces-Extensions-Validator   1
MyFaces Extensions-Validator
             What’s new in version 3




24.03.2010     DI (FH) Gerhard Petracek / MyFaces-Ex...
Agenda - 1
• Bean-Validation Integration Module
     (JSR 303 for JSF 1.x & 2.x + special Features)
• Improved Support for...
Agenda - 2
• SkipValidationEvaluator
• Optional Invocation Order
• Integration of RAD-Add-on
• Additional Static Syntax fo...
Bean-Validation Integration
• JSR 303 for JSF 1.x and JSF 2.x
• Integration Module as alternative/addition
  to the Proper...
ExtVal vs. JSF 2 BV-Integration
• With ExtVal
     • @NotNull validation enabled by default
       (deactivation via std. ...
ExtVal vs. JSF 2 BV-Integration
     • Model based validation
     • Sorted violation messages
     • Out-of-the-box depen...
ExtVal Annotations for BV
• @BeanValidation
  for Group-Validation
• @ModelValidation
  class level validation of an expli...
@BeanValidation
• Normally used in Page-Beans
• Available attributes
     •       viewIds (default: * for all pages)
     ...
@BeanValidation - Examples
• Simple group validation
    @BeanValidation(useGroups=Admin.class)
• Group validation for a s...
@ModelValidation
• To trigger bean-validation after
  „Update model values" phase
• Also uses information of @BeanValidati...
3rd Party Component Libraries
• Improved support for
     • Trinidad
     • ICEfaces
     • RichFaces
• New sandbox projec...
Typesafe Constraint Parameters
• Similar to the payload-attribute of BV
  (Payload is the subset of Constraint
  Parameter...
Constraint Severity
• Constraints with Severity Info and Warn
  don‘t "stop" the JSF-Lifecycle
• ExtVal 1.x.3 provides out...
Optional: Pluggable Parameters
• ExtVal allows to map custom classes to the
  default implementations (esp. to avoid
  dep...
Pluggable Storages
• Generic mechanism which provides scoped
  storages with custom APIs
• Allows to create multiple stora...
Meta-Data Filters
• Filters meta-data before it gets added to the
  meta-data storage
• Only for static meta-data manipula...
Validation Interception - 1
• Invocation:
     • Global interceptors:
       before and after the validation of a property...
Validation Interception - Example
• Implementation
    public class CustomInterceptor
      implements PropertyValidationI...
Validation Interception - Example
• Usage
     • Global interceptors
             ExtValContext.getContext()
             ...
SkipValidationEvaluator
• Evaluates if the validation process for the
  current property should be skipped
• Allows to pro...
Optional Invocation Order
• Classes which implement an interface
  which is annotated with
  @InvocationOrderSupport
  are...
Integration of RAD-Add-on
• It‘s possible to use input components
  without value-bindings.
• Use-Case:
  During prototypi...
Static Syntax for @JoinValidation
• In addition to the existing notations it‘s
  possible to refer a target property via
 ...
Empty-/Null-Value Markers
• Marker for validation strategies instead of
  actively ignoring empty/null values
• Via Annota...
Other Improvements
• Structural improvements
• Performance improvements
• (JSF-) ProjectStage support




24.03.2010   DI ...
New Add-ons - 1
• Add-ons compatible with Property- and
  Bean-Validation module
      • Transactional model validation (l...
New Add-ons - 2
• Bean-Validation module
      • Spring managed constraint validation
        (us dependency injection in ...
Links
• http://svn.apache.org/repos/asf/myfaces/extensi
  ons/validator
• http://issues.apache.org/jira/browse/EXTVAL
• ht...
Upcoming SlideShare
Loading in...5
×

MyFaces Extensions Validator r3 News

4,694

Published on

These slides give a short overview of the new features of the 3rd release of MyFaces ExtVal

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
4,694
On Slideshare
0
From Embeds
0
Number of Embeds
33
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "MyFaces Extensions Validator r3 News"

  1. 1. JSF in der Praxis 24.03.2010 DI (FH) Gerhard Petracek / MyFaces-Extensions-Validator 1
  2. 2. MyFaces Extensions-Validator What’s new in version 3 24.03.2010 DI (FH) Gerhard Petracek / MyFaces-Extensions-Validator 2
  3. 3. Agenda - 1 • Bean-Validation Integration Module (JSR 303 for JSF 1.x & 2.x + special Features) • Improved Support for 3rd Party Component Libraries • Typesafe Constraint Parameters • Constraint Severity • Pluggable Storages • Meta-Data Filters • Validation Interception 24.03.2010 DI (FH) Gerhard Petracek / MyFaces-Extensions-Validator 3
  4. 4. Agenda - 2 • SkipValidationEvaluator • Optional Invocation Order • Integration of RAD-Add-on • Additional Static Syntax for @JoinValidation • Empty-/Null-Value Markers • Other Improvements • New Add-ons 24.03.2010 DI (FH) Gerhard Petracek / MyFaces-Extensions-Validator 4
  5. 5. Bean-Validation Integration • JSR 303 for JSF 1.x and JSF 2.x • Integration Module as alternative/addition to the Property-Validation Module • Compatible with all BV conform implementations • Module provides additional features • Advantage: It’s the (new) standard • Disadvantage: Not all features of ExtVal will be available (due to spec. restrictions) 24.03.2010 DI (FH) Gerhard Petracek / MyFaces-Extensions-Validator 5
  6. 6. ExtVal vs. JSF 2 BV-Integration • With ExtVal • @NotNull validation enabled by default (deactivation via std. JSF config) • Typesafe group validation • No Validation Markup in the Page • The ExtValBeanValidationContext allows custom implementations e.g. tags, configs,… • Component initialization (e.g. @NotNull client-side required) • Severity aware validation 24.03.2010 DI (FH) Gerhard Petracek / MyFaces-Extensions-Validator 6
  7. 7. ExtVal vs. JSF 2 BV-Integration • Model based validation • Sorted violation messages • Out-of-the-box dependency injection support for constraint-validators 24.03.2010 DI (FH) Gerhard Petracek / MyFaces-Extensions-Validator 7
  8. 8. ExtVal Annotations for BV • @BeanValidation for Group-Validation • @ModelValidation class level validation of an explicit or implicit target 24.03.2010 DI (FH) Gerhard Petracek / MyFaces-Extensions-Validator 8
  9. 9. @BeanValidation • Normally used in Page-Beans • Available attributes • viewIds (default: * for all pages) • useGroups (default: Default.class) • restrictGroups (default: -) • conditions (default: #{true}) • modelValidation (default: -) • List (equivalent to multi-constraint syntax of JSR 303) 24.03.2010 DI (FH) Gerhard Petracek / MyFaces-Extensions-Validator 9
  10. 10. @BeanValidation - Examples • Simple group validation @BeanValidation(useGroups=Admin.class) • Group validation for a specific view @BeanValidation(viewIds="/login.xhtml", useGroups=Admin.class) • If group validation is defined for the whole bean, it might be required to exclude groups for special properties and/or views @BeanValidation(restrictGroups=Admin.class) • Conditional group validation @BeanValidation(useGroups = Admin.class, conditions="#{user.role.privileged}") 24.03.2010 DI (FH) Gerhard Petracek / MyFaces-Extensions-Validator 10
  11. 11. @ModelValidation • To trigger bean-validation after „Update model values" phase • Also uses information of @BeanValidation • Difference: @ModelValidation isn‘t accumulated • Available attributes • isActive (default: false) • displayInline (default: false) • validationTargets (default: current base object) • message (default: -) 24.03.2010 DI (FH) Gerhard Petracek / MyFaces-Extensions-Validator 11
  12. 12. 3rd Party Component Libraries • Improved support for • Trinidad • ICEfaces • RichFaces • New sandbox project e.g. for external component support modules to improve compatibility with 3rd party component libraries (http://code.google.com/p/sandbox890) 24.03.2010 DI (FH) Gerhard Petracek / MyFaces-Extensions-Validator 12
  13. 13. Typesafe Constraint Parameters • Similar to the payload-attribute of BV (Payload is the subset of Constraint Parameters of ExtVal) • Allows typesafe and reusable parameters • Simple example - alternative for: @MyConstraint(payload = "warn") With Bean-Validation: @MyConstraint(payload = Warn.class) • Processed by Add-ons or Component Libraries 24.03.2010 DI (FH) Gerhard Petracek / MyFaces-Extensions-Validator 13
  14. 14. Constraint Severity • Constraints with Severity Info and Warn don‘t "stop" the JSF-Lifecycle • ExtVal 1.x.3 provides out-of-the-box • ViolationSeverity.Info.class • ViolationSeverity.Warn.class • ViolationSeverity.Error.class (= default) • ViolationSeverity.Fatal.class 24.03.2010 DI (FH) Gerhard Petracek / MyFaces-Extensions-Validator 14
  15. 15. Optional: Pluggable Parameters • ExtVal allows to map custom classes to the default implementations (esp. to avoid dependencies of BV Constraints to ExtVal) • Mapping via • Global-ExtVal-Parameter • Static config • Examples are available in the ExtVal Wiki 24.03.2010 DI (FH) Gerhard Petracek / MyFaces-Extensions-Validator 15
  16. 16. Pluggable Storages • Generic mechanism which provides scoped storages with custom APIs • Allows to create multiple storages of the same type with different names • Allows to create different storage types • StorageManager (per storage type) • Responsible for scoping • Allows to create and reset (custom) storages via an API (independent of the storage type) • Allows to provide custom (tweaked) storage implementations easily 24.03.2010 DI (FH) Gerhard Petracek / MyFaces-Extensions-Validator 16
  17. 17. Meta-Data Filters • Filters meta-data before it gets added to the meta-data storage • Only for static meta-data manipulation • Meta-data extraction interceptors are only for dynamic meta-data manipulation 24.03.2010 DI (FH) Gerhard Petracek / MyFaces-Extensions-Validator 17
  18. 18. Validation Interception - 1 • Invocation: • Global interceptors: before and after the validation of a property • Local interceptors: before and after the validation of a constraint • Allows to bypass validation of a • Property • Constraint 24.03.2010 DI (FH) Gerhard Petracek / MyFaces-Extensions-Validator 18
  19. 19. Validation Interception - Example • Implementation public class CustomInterceptor implements PropertyValidationInterceptor { public boolean beforeValidation( FacesContext fC, UIComponent c, Object convertedObject, Map<String, Object> p) { //... return true; } public void afterValidation( FacesContext fC, UIComponent c, Object convertedObject, Map<String, Object> p) { //... } } 24.03.2010 DI (FH) Gerhard Petracek / MyFaces-Extensions-Validator 19
  20. 20. Validation Interception - Example • Usage • Global interceptors ExtValContext.getContext() .addPropertyValidationInterceptor( new CustomInterceptor()); • Local interceptors @Required(parameters = CustomInterceptor.class) private String name; 24.03.2010 DI (FH) Gerhard Petracek / MyFaces-Extensions-Validator 20
  21. 21. SkipValidationEvaluator • Evaluates if the validation process for the current property should be skipped • Allows to provide a custom evaluator 24.03.2010 DI (FH) Gerhard Petracek / MyFaces-Extensions-Validator 21
  22. 22. Optional Invocation Order • Classes which implement an interface which is annotated with @InvocationOrderSupport are allowed to use @InvocationOrder • The annotation allows to register artifacts which get called e.g. before internal artifacts • Default order: 1000 24.03.2010 DI (FH) Gerhard Petracek / MyFaces-Extensions-Validator 22
  23. 23. Integration of RAD-Add-on • It‘s possible to use input components without value-bindings. • Use-Case: During prototyping sometimes developers have to create dummy pages without functionality. 24.03.2010 DI (FH) Gerhard Petracek / MyFaces-Extensions-Validator 23
  24. 24. Static Syntax for @JoinValidation • In addition to the existing notations it‘s possible to refer a target property via the fully qualified class name + the property name • Example: @JoinValidation("at.irian.demo.domain.Person:password") 24.03.2010 DI (FH) Gerhard Petracek / MyFaces-Extensions-Validator 24
  25. 25. Empty-/Null-Value Markers • Marker for validation strategies instead of actively ignoring empty/null values • Via Annotations • @EmptyValueAwareValidationStrategy • @NullValueAwareValidationStrategy 24.03.2010 DI (FH) Gerhard Petracek / MyFaces-Extensions-Validator 25
  26. 26. Other Improvements • Structural improvements • Performance improvements • (JSF-) ProjectStage support 24.03.2010 DI (FH) Gerhard Petracek / MyFaces-Extensions-Validator 26
  27. 27. New Add-ons - 1 • Add-ons compatible with Property- and Bean-Validation module • Transactional model validation (light) • Continue with warnings • Add-ons compatible with Property- Validation module • Advanced meta-data • Java based config (Syntax inspired by Google Guice) 24.03.2010 DI (FH) Gerhard Petracek / MyFaces-Extensions-Validator 27
  28. 28. New Add-ons - 2 • Bean-Validation module • Spring managed constraint validation (us dependency injection in custom constraint validator implementations) 24.03.2010 DI (FH) Gerhard Petracek / MyFaces-Extensions-Validator 28
  29. 29. Links • http://svn.apache.org/repos/asf/myfaces/extensi ons/validator • http://issues.apache.org/jira/browse/EXTVAL • http://wiki.apache.org/myfaces/Extensions/Valid ator/Versions/Versions/UpgradeGuide • http://os890.blogspot.com • http://code.google.com/p/os890/source/browse/tr unk/java/web/jsf/extval • http://people.apache.org/~gpetracek/myfaces/ex tval 24.03.2010 DI (FH) Gerhard Petracek / MyFaces-Extensions-Validator 29

×