hi rudy, it's an external add-on, therefore we shouldn't use the jira of apache. thx for the patch. i'll review and commit it as soon as possible.
regards, gerhard http://www.irian.at Your JSF powerhouse - JSF Consulting, Development and Courses in English and German Professional Support for Apache MyFaces 2010/4/21 Rudy De Busscher <[email protected]> > Using the @VirtualMetaData can lead to disabling some validation checks. > > When we have for example the following code > > @Column(nullable = false, length = 50) > @VirtualMetaData(target=Column.class, parameters = > {ViolationSeverity.Warn.class}) > private String firstName; > > No validation messages are generated when we try to set the field to an > empty value. > > The issue is tracked back to the isValidationStrategyCompatibleWithValue > method of ValidationInterceptor class. > This method verifies if the validation has to be performed by looking at > the annotation on the ValidationStrategy class. The Column validation is > only performed as part of > the VirtualMetaData validation (done by VirtualMetaDataInterceptor a > MetaDataExtractionInterceptor). > > But since the VirtualMetaDataStrategy has no > EmptyValueAwareValidationStrategy annotation, the system decides that no > validation needs to be done when the field is empty. > > The correct behaviour would be that isValidationStrategyCompatibleWithValue > looks at the target validation strategy (in our example > JpaValidaitonStrategy for the JPA Column > > annotation) to determine if the validation should be done or not. > > Therefor the following changes need to be made: > - Add parameter MetaDataEntry to the method > isValidationStrategyCompatibleWithValue > - Add a VirtualValidationInterceptor to the add-on that looks like > > public class VirtualValidationInterceptor extends > PropertyValidationModuleValidationInterceptor > { > > @Override > protected boolean isValidationStrategyCompatibleWithValue( > ValidationStrategy validationStrategy, Object value, > MetaDataEntry metaDataEntry) > { > if (validationStrategy instanceof VirtualMetaDataStrategy) > { > > ValidationStrategy targetValidationStrategy = ExtValUtils > .getValidationStrategyForMetaData(metaDataEntry > .getProperty(VirtualMetaData.TARGET, > MetaDataEntry.class).getKey()); > > return > isValidationStrategyCompatibleWithValue(targetValidationStrategy, > value, > metaDataEntry.getProperty(VirtualMetaData.TARGET, MetaDataEntry.class)); > } > > return > super.isValidationStrategyCompatibleWithValue(validationStrategy, > value, metaDataEntry); > } > > } > > With the bean validation module there is no issue since it uses another > 'ValidationInterceptor. > > Create JIRA issue for it and supply patch ?? > > Regards > Rudy. >
