On Tue, 2006-08-08 at 08:36 -0700, Igor Vaynberg wrote: > this only solves it partially though - added formvalidators are still > going to be a problem for removed items - not sure about the best > approach right now - we might have to open more api or make validation > smarter - lets discuss this some more.
I think the problem is that IFormValidators are pushed to a Form. Pushing things do not work well when using pull models. What if Form would pull FormValidators instead: public Form extends WebMarkupContainer implements IFormSubmitListener { ... protected List<IFormValidator> formValidators() { List<IFormValidator> formValidators = new ArrayList<IFormValidator>(); visitChildren(IFormValidatorProvider.class, new IVisitor() { public Object component(final Component component) { IFormValidatorProvider provider = (IFormValidatorProvider) component; validators.addAll(provider.formValidators()); return CONTINUE_TRAVERSAL; } }); return formValidators; } } public interface IFormValidatorProvider { Collection<IFormValidator> formValidators(); } This would allow IFormValidators to be encapsulated with components. E.g. public DateRangePicker extends Panel implements IFormValidatorProvider { public DateRangePicker(String id) { super(id); start = new DateRange("start"); end = new DateRange("end"); } public Collection<IFormValidator> formValidators() { return Arrays.asList(new DateRangePickerValidator(start, end)); } private class DateRangePickerValidator implements IFormValidator { public DateRangeFieldValidator(DatePicker start, DatePicker end) { } } } This would also be more flexible than the current way since the decision about whether to include a certain IFormValidator can be done at onSubmit() phase. Any comments? Joni ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user