JSF in der Praxis
28.11.2010 1DI (FH) Gerhard Petracek / MyFaces-Extensions-Validator
28.11.2010 DI (FH) Gerhard Petracek / MyFaces-Extensions-Validator 2
MyFaces Extensions-Validator
What’s new in version 4
28.11.2010 DI (FH) Gerhard Petracek / MyFaces-Extensions-Validator 3
Agenda
• Mapped Constraint Sources
• Performance Impr...
28.11.2010 DI (FH) Gerhard Petracek / MyFaces-Extensions-Validator 4
Mapped Constraint Sources - 1
• The problem
• Multipl...
28.11.2010 DI (FH) Gerhard Petracek / MyFaces-Extensions-Validator 5
Mapped Constraint Sources - 2
• Simple Example
@Const...
28.11.2010 DI (FH) Gerhard Petracek / MyFaces-Extensions-Validator 6
Mapped Constraint Sources - 2
• Further annotations f...
28.11.2010 DI (FH) Gerhard Petracek / MyFaces-Extensions-Validator 7
Performance Improvements
28.11.2010 DI (FH) Gerhard Petracek / MyFaces-Extensions-Validator 8
New and Improved Constraints
• New Constraints
• @Emp...
28.11.2010 DI (FH) Gerhard Petracek / MyFaces-Extensions-Validator 9
@EmptyIf Constraint - 1
• Example 1
public class MyBe...
28.11.2010 DI (FH) Gerhard Petracek / MyFaces-Extensions-Validator 10
@EmptyIf Constraint - 2
• Example 2
public class MyB...
28.11.2010 DI (FH) Gerhard Petracek / MyFaces-Extensions-Validator 11
Type-safe Config - 1
• Instead of conversations or c...
28.11.2010 DI (FH) Gerhard Petracek / MyFaces-Extensions-Validator 12
Type-safe Config - 2
• Example
Extend the default or...
28.11.2010 DI (FH) Gerhard Petracek / MyFaces-Extensions-Validator 13
Support for @Valid (BV Module) - 1
• MyFaces ExtVal ...
28.11.2010 DI (FH) Gerhard Petracek / MyFaces-Extensions-Validator 14
Support for @Valid (BV Module) - 2
• Example
public ...
28.11.2010 DI (FH) Gerhard Petracek / MyFaces-Extensions-Validator 15
Interoperability
• MyFaces CODI
• CDI based dependen...
28.11.2010 DI (FH) Gerhard Petracek / MyFaces-Extensions-Validator 16
Misc
• Improved JSF 2.0 support
• Bugfixing based on...
28.11.2010 DI (FH) Gerhard Petracek / MyFaces-Extensions-Validator 17
Links
• http://svn.apache.org/repos/asf/myfaces/exte...
Upcoming SlideShare
Loading in …5
×

MyFaces Extensions Validator r4 news

5,007 views

Published on

These slides give a short overview of the new features of the 4th release of MyFaces ExtVal

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
5,007
On SlideShare
0
From Embeds
0
Number of Embeds
2,636
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

MyFaces Extensions Validator r4 news

  1. 1. JSF in der Praxis 28.11.2010 1DI (FH) Gerhard Petracek / MyFaces-Extensions-Validator
  2. 2. 28.11.2010 DI (FH) Gerhard Petracek / MyFaces-Extensions-Validator 2 MyFaces Extensions-Validator What’s new in version 4
  3. 3. 28.11.2010 DI (FH) Gerhard Petracek / MyFaces-Extensions-Validator 3 Agenda • Mapped Constraint Sources • Performance Improvements • New and Improved Constraints • Type-safe Config (Java-Config) • Support for @Valid • Interoperability • Misc
  4. 4. 28.11.2010 DI (FH) Gerhard Petracek / MyFaces-Extensions-Validator 4 Mapped Constraint Sources - 1 • The problem • Multiple classes might contain the same properties (e.g. DTOs, PageBeans,…) • Some architectures don’t allow e.g. to share the domain model across layers • That violates the DRY principle for constraints • The solution • Annotations for referencing the source of a constraint • Works for ExtVal as well as BV constraints
  5. 5. 28.11.2010 DI (FH) Gerhard Petracek / MyFaces-Extensions-Validator 5 Mapped Constraint Sources - 2 • Simple Example @ConstraintSource(User.class) public class UserDTO { //mapped automatically to User#firstName private String firstName; //mapped automatically to User#lastName private String lastName; //... }
  6. 6. 28.11.2010 DI (FH) Gerhard Petracek / MyFaces-Extensions-Validator 6 Mapped Constraint Sources - 2 • Further annotations for properties • @ConstraintSource • @TargetProperty • @TargetPropertyId • @IgnoreConstraintSource • These annotations allow to • map to a property with a different name (same source) • map to a different constraint source • ignore the constraint source for a property
  7. 7. 28.11.2010 DI (FH) Gerhard Petracek / MyFaces-Extensions-Validator 7 Performance Improvements
  8. 8. 28.11.2010 DI (FH) Gerhard Petracek / MyFaces-Extensions-Validator 8 New and Improved Constraints • New Constraints • @EmptyIf • Improved • @Equals and @NotEquals • Configurable message-target (#validationErrorMsgTarget) • Optional case-insensitive text comparisons (via Constraint-Parameter: CaseInsensitive)
  9. 9. 28.11.2010 DI (FH) Gerhard Petracek / MyFaces-Extensions-Validator 9 @EmptyIf Constraint - 1 • Example 1 public class MyBean { private String property1; //has to be empty if property1 is not empty @EmptyIf(valueOf = "property1") private String property2; //... }
  10. 10. 28.11.2010 DI (FH) Gerhard Petracek / MyFaces-Extensions-Validator 10 @EmptyIf Constraint - 2 • Example 2 public class MyBean { private String property1; //has to be empty if property1 is empty @EmptyIf(valueOf = "property1", is = empty) private String property2; //... }
  11. 11. 28.11.2010 DI (FH) Gerhard Petracek / MyFaces-Extensions-Validator 11 Type-safe Config - 1 • Instead of conversations or configuration via web.xml ExtVal now allows to use a simple Java-API within Startup-Listeners
  12. 12. 28.11.2010 DI (FH) Gerhard Petracek / MyFaces-Extensions-Validator 12 Type-safe Config - 2 • Example Extend the default or abstract implementations of a config (e.g. ExtValCoreConfiguration) and register it via: ExtValCoreConfiguration.use( customExtValCoreConfiguration, true);
  13. 13. 28.11.2010 DI (FH) Gerhard Petracek / MyFaces-Extensions-Validator 13 Support for @Valid (BV Module) - 1 • MyFaces ExtVal allows validation of constraints within custom types via the @Valid BV-Annotation
  14. 14. 28.11.2010 DI (FH) Gerhard Petracek / MyFaces-Extensions-Validator 14 Support for @Valid (BV Module) - 2 • Example public class CustomType { @NotNull private String property1; @Size(min = 3) private String property2; //... } public class MyBean { @NotNull @Valid private CustomType property; //... } Constraints within a cusotm type.
  15. 15. 28.11.2010 DI (FH) Gerhard Petracek / MyFaces-Extensions-Validator 15 Interoperability • MyFaces CODI • CDI based dependency injection for constraints validators will be done by CODI if both libs are used. • MyFaces Ext-Script
  16. 16. 28.11.2010 DI (FH) Gerhard Petracek / MyFaces-Extensions-Validator 16 Misc • Improved JSF 2.0 support • Bugfixing based on Community Feedback • Moved to JUL (from Commons-Logging) • Improved JavaDoc and JUnit Tests • Started to move the documentation to http://cwiki.apache.org/confluence/display/EXTVAL/ • Add-ons • Multi-Field-Validation for BV (new) • Required Label (new) • Existing Add-ons will continue at Bitbucket
  17. 17. 28.11.2010 DI (FH) Gerhard Petracek / MyFaces-Extensions-Validator 17 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://bitbucket.org/os890/ • http://people.apache.org/~gpetracek/myfaces/ex tval

×