Hi Mike, Comments inlined...
2009/3/1 Mike McNally <[email protected]>: > The validation metadata mechanism in Stripes is very "static". All > the validatio rules are maintained on a per-class basis. Exactly, that's my problem :) > Thus, what my subclass of DefaultValidationMetadataProvider does is to > make it look like the ActionBean actually had all the appropriate > information in it. In other words, my code tells the Stripes system > the same thing Stripes would see if the action bean had a big > "ValidateNestedProperties" annotation on it. So I guess you have everything available from the bean Class... Again, that's not enough for me :( > The validation *metadata* tells the Stripes runtime code how to do the > validation on the actual instance data from the HTTP request. In > other words, the job of the ValidationMetadataProvider is to translate > the annotations into the data structures that Stripes will actually > use at runtime. Does that make sense? Yeah I've read the code, and again, that's my problem... I have managed to get my stuff work by extending only DefaultActionBeanPropertyBinder, but I had to override several methods because there's no hook for instance-specific Validation things : public ValidationErrors bind(ActionBean bean, ActionBeanContext context, boolean validate) protected SortedMap<ParameterName, String[]> getParameters(ActionBean bean) { protected void validateRequiredFields(Map<ParameterName, String[]> parameters, ActionBean bean, ValidationErrors errors) Actually I had to overwrite all methods that invoke the ValidationMetadataProvider, and do stuff like this : Map<String, ValidationMetadata> validationInfos = this.getConfiguration() .getValidationMetadataProvider().getValidationMetadata(bean.getClass()); // append dynamic validation info if needed validationInfos = appendDynamicValidationMetadata(bean, validationInfos); The resulting class is pretty crappy as you may guess : it's the overridebn methods copy-pasted with the "dynamic hook" added... Even if I don't really like broken windows like this one, I think I can live with it for a while. But I think I'll have to think of a better solution some day... Anybody else interested in the feature (recursive validation annotations) ? Maybe it deserves a JIRA ticket (if none already exists)... Cheers Remi ------------------------------------------------------------------------------ Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise -Strategies to boost innovation and cut costs with open source participation -Receive a $600 discount off the registration fee with the source code: SFAD http://p.sf.net/sfu/XcvMzF8H _______________________________________________ Stripes-development mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/stripes-development
