<joni_18912> ivaynberg: any opinions on IFormValidator issue? Currently it is very difficult to work with them if the components in a Form change
<ivaynberg> joni_18912 i think what you suggest works
<ivaynberg> but you do realize that you can implement that yourself by subclassing the form?
<ivaynberg> we need to discuss this with chillenious and jcompagner here because usually we all disagree as far as changes to core form processing goes :)
<joni_18912> ok :)
<chillenious> :)
<chillenious> what's the proposal
<chillenious> ?
<chillenious> that IFormValidator was a nasty bugger
<joni_18912> chillenious: http://thread.gmane.org/gmane.comp.java.wicket.user/15627/focus=15643
<chillenious> ah, I read the thread but missed the proposal part
<joni_18912> only that i don't see how it is possible to implement it  by subclassing the form. only way to get IFormValidators to a form is by pushing them
<ivaynberg> you override validate()
<ivaynberg> and process them yourself
<joni_18912> right
<ivaynberg> after some discussions i am a bit hesitant of adding more stuff to form processing
<ivaynberg> cause it seems everyone expects it to work slightly different
<ivaynberg> so it just makes more of a mess
<chillenious> yeah I agree
<ivaynberg> but
<chillenious> better keep it simple if we can
<ivaynberg> what i can do is break out validate(IFormValidator) for you so when you override validate and collect the validators you can just delegate to that call
<ivaynberg> so you dont have to rewrite as much
<ivaynberg> sound good?
<joni_18912> that would be good
<ivaynberg> ok
<chillenious> to me that does sound good too
<ivaynberg> let me do that right now
<joni_18912> ty
<ivaynberg> np
<chillenious> better than the lazy loading thing. That's a nice pattern in itself, but it would add more complexity (not to mention another API break)
<ivaynberg> i think a wiki page with the visitor would be nice in case someone else runs into this

-Igor


On 8/8/06, Joni Freeman <[EMAIL PROTECTED]> wrote:
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user

-------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to