It is needed i guess if we say that the method
protected abstract void onSubmit(AjaxRequestTarget ajaxrequesttarget, Form
form1);

needs a form parameter that can't be null

Also i see something strange in the AjaxButton because if you dont give the
form then the form parameter
can be null:

 public AjaxButton(String id)
    {
        this(id, null);
    }

    public Form getForm()
    {
        if(form != null)
            return form;
        else
            return super.getForm();
    }

    public AjaxButton(String id, final Form form)
    {
        super(id);
        this.form = form;
        add(new AjaxFormSubmitBehavior("onclick", form) {

            protected void onSubmit(AjaxRequestTarget target)
            {
                AjaxButton.this.onSubmit(target, form);
            }

            protected void onError(AjaxRequestTarget target)
            {
                AjaxButton.this.onError(target, form);
            }

i think this is wrong, but maybe it was on purpose?
i think it should be:

 public AjaxButton(String id)
    {
        this(id, null);
    }

    public Form getForm()
    {
        if(form != null)
            return form;
        else
            return super.getForm();
    }

    public AjaxButton(String id, final Form form)
    {
        super(id);
        this.form = form;
        add(new AjaxFormSubmitBehavior("onclick", form) {

            protected void onSubmit(AjaxRequestTarget target)
            {
                AjaxButton.this.onSubmit(target, getForm());
            }

            protected void onError(AjaxRequestTarget target)
            {
                AjaxButton.this.onError(target, getForm());
            }

So that we return the given form or try to find one.

johan



On 9/3/07, Sam Hough <[EMAIL PROTECTED]> wrote:
>
>
> Since neither AjaxButton or Button require Form in the constructor why
> does
> AjaxFallbackButton? Seems a shame to make it required if not really
> needed...
>
> I'm not quite clear from the source or comments what the difference is in
> AjaxButton between the behaviour from the two different constructors...
> --
> View this message in context:
> http://www.nabble.com/AjaxFallbackButton-really-require-Form-in-constructor--tf4370843.html#a12457890
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

Reply via email to