SlideShare une entreprise Scribd logo
1  sur  17
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 Improvements
• New and Improved Constraints
• Type-safe Config (Java-Config)
• Support for @Valid
• Interoperability
• Misc
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
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;
//...
}
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
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
• @EmptyIf
• Improved
• @Equals and @NotEquals
• Configurable message-target
(#validationErrorMsgTarget)
• Optional case-insensitive text comparisons
(via Constraint-Parameter: CaseInsensitive)
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;
//...
}
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;
//...
}
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
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);
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
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.
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
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
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

Contenu connexe

En vedette (14)

100470
100470100470
100470
 
100486
100486100486
100486
 
100455
100455100455
100455
 
100358
100358100358
100358
 
Persija jakarta
Persija jakartaPersija jakarta
Persija jakarta
 
Introducing Mozilla Test Pilot - Data Policy
Introducing Mozilla Test Pilot - Data PolicyIntroducing Mozilla Test Pilot - Data Policy
Introducing Mozilla Test Pilot - Data Policy
 
100510
100510100510
100510
 
경마전략┣〓〓┫▶SX797.COM ◀┣〓〓┫경마전략 게임장 동영상
경마전략┣〓〓┫▶SX797.COM ◀┣〓〓┫경마전략 게임장 동영상경마전략┣〓〓┫▶SX797.COM ◀┣〓〓┫경마전략 게임장 동영상
경마전략┣〓〓┫▶SX797.COM ◀┣〓〓┫경마전략 게임장 동영상
 
100350
100350100350
100350
 
La web 2.0 carlos peña arrieta
La web 2.0 carlos peña arrietaLa web 2.0 carlos peña arrieta
La web 2.0 carlos peña arrieta
 
100479
100479100479
100479
 
100362
100362100362
100362
 
Bee venom therapy
Bee venom therapyBee venom therapy
Bee venom therapy
 
Professional Ethics-Notes
Professional Ethics-NotesProfessional Ethics-Notes
Professional Ethics-Notes
 

Similaire à MyFaces Extensions Validator r4 news

Apache DeltaSpike
Apache DeltaSpikeApache DeltaSpike
Apache DeltaSpikeos890
 
The Beauty and the Beast
The Beauty and the BeastThe Beauty and the Beast
The Beauty and the BeastBastian Feder
 
Integration Group - Robot Framework
Integration Group - Robot Framework Integration Group - Robot Framework
Integration Group - Robot Framework OpenDaylight
 
The Beauty And The Beast Php N W09
The Beauty And The Beast Php N W09The Beauty And The Beast Php N W09
The Beauty And The Beast Php N W09Bastian Feder
 
Context and Dependency Injection 2.0
Context and Dependency Injection 2.0Context and Dependency Injection 2.0
Context and Dependency Injection 2.0Brian S. Paskin
 
FileWrite.javaFileWrite.java  To change this license header.docx
FileWrite.javaFileWrite.java  To change this license header.docxFileWrite.javaFileWrite.java  To change this license header.docx
FileWrite.javaFileWrite.java  To change this license header.docxssuser454af01
 
The beautyandthebeast phpbat2010
The beautyandthebeast phpbat2010The beautyandthebeast phpbat2010
The beautyandthebeast phpbat2010Bastian Feder
 
Flink and Hive integration - unifying enterprise data processing systems
Flink and Hive integration - unifying enterprise data processing systemsFlink and Hive integration - unifying enterprise data processing systems
Flink and Hive integration - unifying enterprise data processing systemsBowen Li
 
Unify Enterprise Data Processing System Platform Level Integration of Flink a...
Unify Enterprise Data Processing System Platform Level Integration of Flink a...Unify Enterprise Data Processing System Platform Level Integration of Flink a...
Unify Enterprise Data Processing System Platform Level Integration of Flink a...Flink Forward
 
The Eclipse Transformer Project
The Eclipse Transformer Project The Eclipse Transformer Project
The Eclipse Transformer Project Jakarta_EE
 
Building a Personal Cloud Storage Service
Building a Personal Cloud Storage ServiceBuilding a Personal Cloud Storage Service
Building a Personal Cloud Storage ServiceTesora
 
Jetpack, with new features in 2021 GDG Georgetown IO Extended
Jetpack, with new features in 2021 GDG Georgetown IO ExtendedJetpack, with new features in 2021 GDG Georgetown IO Extended
Jetpack, with new features in 2021 GDG Georgetown IO ExtendedToru Wonyoung Choi
 
StorageQuery: federated querying on object stores, powered by Alluxio and Presto
StorageQuery: federated querying on object stores, powered by Alluxio and PrestoStorageQuery: federated querying on object stores, powered by Alluxio and Presto
StorageQuery: federated querying on object stores, powered by Alluxio and PrestoAlluxio, Inc.
 
Poco Es Mucho: WCF, EF, and Class Design
Poco Es Mucho: WCF, EF, and Class DesignPoco Es Mucho: WCF, EF, and Class Design
Poco Es Mucho: WCF, EF, and Class DesignJames Phillips
 
MicroProfile Devoxx.us
MicroProfile Devoxx.usMicroProfile Devoxx.us
MicroProfile Devoxx.usjclingan
 
DSD-INT 2018 Setting up an automated test environment in the context of Delft...
DSD-INT 2018 Setting up an automated test environment in the context of Delft...DSD-INT 2018 Setting up an automated test environment in the context of Delft...
DSD-INT 2018 Setting up an automated test environment in the context of Delft...Deltares
 
Perfomatix - Java Coding Standards
Perfomatix - Java Coding StandardsPerfomatix - Java Coding Standards
Perfomatix - Java Coding StandardsPerfomatix Solutions
 

Similaire à MyFaces Extensions Validator r4 news (20)

Apache DeltaSpike
Apache DeltaSpikeApache DeltaSpike
Apache DeltaSpike
 
The Beauty and the Beast
The Beauty and the BeastThe Beauty and the Beast
The Beauty and the Beast
 
Integration Group - Robot Framework
Integration Group - Robot Framework Integration Group - Robot Framework
Integration Group - Robot Framework
 
The Beauty And The Beast Php N W09
The Beauty And The Beast Php N W09The Beauty And The Beast Php N W09
The Beauty And The Beast Php N W09
 
Context and Dependency Injection 2.0
Context and Dependency Injection 2.0Context and Dependency Injection 2.0
Context and Dependency Injection 2.0
 
FileWrite.javaFileWrite.java  To change this license header.docx
FileWrite.javaFileWrite.java  To change this license header.docxFileWrite.javaFileWrite.java  To change this license header.docx
FileWrite.javaFileWrite.java  To change this license header.docx
 
The beautyandthebeast phpbat2010
The beautyandthebeast phpbat2010The beautyandthebeast phpbat2010
The beautyandthebeast phpbat2010
 
Java se7 features
Java se7 featuresJava se7 features
Java se7 features
 
Flink and Hive integration - unifying enterprise data processing systems
Flink and Hive integration - unifying enterprise data processing systemsFlink and Hive integration - unifying enterprise data processing systems
Flink and Hive integration - unifying enterprise data processing systems
 
Unify Enterprise Data Processing System Platform Level Integration of Flink a...
Unify Enterprise Data Processing System Platform Level Integration of Flink a...Unify Enterprise Data Processing System Platform Level Integration of Flink a...
Unify Enterprise Data Processing System Platform Level Integration of Flink a...
 
The Eclipse Transformer Project
The Eclipse Transformer Project The Eclipse Transformer Project
The Eclipse Transformer Project
 
Building a Personal Cloud Storage Service
Building a Personal Cloud Storage ServiceBuilding a Personal Cloud Storage Service
Building a Personal Cloud Storage Service
 
Java 7: Quo vadis?
Java 7: Quo vadis?Java 7: Quo vadis?
Java 7: Quo vadis?
 
Jetpack, with new features in 2021 GDG Georgetown IO Extended
Jetpack, with new features in 2021 GDG Georgetown IO ExtendedJetpack, with new features in 2021 GDG Georgetown IO Extended
Jetpack, with new features in 2021 GDG Georgetown IO Extended
 
StorageQuery: federated querying on object stores, powered by Alluxio and Presto
StorageQuery: federated querying on object stores, powered by Alluxio and PrestoStorageQuery: federated querying on object stores, powered by Alluxio and Presto
StorageQuery: federated querying on object stores, powered by Alluxio and Presto
 
Poco Es Mucho: WCF, EF, and Class Design
Poco Es Mucho: WCF, EF, and Class DesignPoco Es Mucho: WCF, EF, and Class Design
Poco Es Mucho: WCF, EF, and Class Design
 
MicroProfile Devoxx.us
MicroProfile Devoxx.usMicroProfile Devoxx.us
MicroProfile Devoxx.us
 
DSD-INT 2018 Setting up an automated test environment in the context of Delft...
DSD-INT 2018 Setting up an automated test environment in the context of Delft...DSD-INT 2018 Setting up an automated test environment in the context of Delft...
DSD-INT 2018 Setting up an automated test environment in the context of Delft...
 
Iffy
IffyIffy
Iffy
 
Perfomatix - Java Coding Standards
Perfomatix - Java Coding StandardsPerfomatix - Java Coding Standards
Perfomatix - Java Coding Standards
 

MyFaces Extensions Validator r4 news

  • 1. JSF in der Praxis 28.11.2010 1DI (FH) Gerhard Petracek / MyFaces-Extensions-Validator
  • 2. 28.11.2010 DI (FH) Gerhard Petracek / MyFaces-Extensions-Validator 2 MyFaces Extensions-Validator What’s new in version 4
  • 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. 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. 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. 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. 28.11.2010 DI (FH) Gerhard Petracek / MyFaces-Extensions-Validator 7 Performance Improvements
  • 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. 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. 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. 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. 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. 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. 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. 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. 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. 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