You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Ajayi Yinka <ia...@googlemail.com> on 2014/09/21 09:48:57 UTC

clicking Ajax SubmitLink button called submit method twice

Hello everyone,

submit method called more than one time trigering two modalWindows to open
at the same time.

See snippet below. If I put the just only modal.show(target) in the
onsubmit method and others in Page constuctor, the problem still persist.

I am using version 6.16.

What am I doing wrong here? I will appreciate better way of doing this.


AjaxSubmitLink addButton = new AjaxSubmitLink("addButton") {
            @Override
            public void onSubmit(AjaxRequestTarget target,  Form form) {
                // your stuff
                if (target != null) {
                    Object obj= new Object();
                    Object Panel panel = new
ObjectPanel(modalWindow.getContentId(), object);
                    modalWindow.setContent(panel);
                    modalWindow.setTitle("New Object");
                    //modalWindow.setEnabled(true);
                    //modalWindow.showUnloadConfirmation(true);

                        modalWindow.show(target);
                        System.out.println("\n\nI am called
1111111111111111111111111111111" + target.getLastFocusedElementId());

                }
            }
        };


        Form form = new Form("form");

        form.add(modalWindow);
        form.add(addButton);



Thank you.

-- 

Ajayi S . Yinka
+2348022684477

Re: clicking Ajax SubmitLink button called submit method twice

Posted by Ajayi Yinka <ia...@googlemail.com>.
Martin,


I have logged the issue in Jira with a quick start project. the ticket id
is
WICKET-5707 <https://issues.apache.org/jira/browse/WICKET-5707>. I do not
like the work-around as it makes the code messy.

Thanks you in anticipation of a quick fix.



On 21 September 2014 20:06, Ajayi Yinka <ia...@googlemail.com> wrote:

>
> Thank you Martin,
>
> I change the implementation to below and its working fine now.
>
> Add this to Html
> <div wicket:id="panel"> </div>
>
> change the add(form) to
>
> add(new Panel("panel", object));
>
> the modal window is implemented in panel
>
> For the purpose of checking, I will create the quickstart how it was
> implemented before as you requested.
>
>
>
> On 21 September 2014 16:45, Martin Grigorov <mg...@apache.org> wrote:
>
>> Hi,
>>
>> On Sun, Sep 21, 2014 at 10:48 AM, Ajayi Yinka <iamstyajayi@googlemail.com
>> >
>> wrote:
>>
>> > Hello everyone,
>> >
>> > submit method called more than one time trigering two modalWindows to
>> open
>> > at the same time.
>> >
>> > See snippet below. If I put the just only modal.show(target) in the
>> > onsubmit method and others in Page constuctor, the problem still
>> persist.
>> >
>> > I am using version 6.16.
>> >
>> > What am I doing wrong here? I will appreciate better way of doing this.
>> >
>> >
>> > AjaxSubmitLink addButton = new AjaxSubmitLink("addButton") {
>> >             @Override
>> >             public void onSubmit(AjaxRequestTarget target,  Form form) {
>> >                 // your stuff
>> >                 if (target != null) {
>> >
>>
>> target should be always non-null here
>>
>>
>> >                     Object obj= new Object();
>> >                     Object Panel panel = new
>> > ObjectPanel(modalWindow.getContentId(), object);
>> >                     modalWindow.setContent(panel);
>> >                     modalWindow.setTitle("New Object");
>> >                     //modalWindow.setEnabled(true);
>> >                     //modalWindow.showUnloadConfirmation(true);
>> >
>> >                         modalWindow.show(target);
>> >                         System.out.println("\n\nI am called
>> > 1111111111111111111111111111111" + target.getLastFocusedElementId());
>> >
>> >                 }
>> >             }
>> >         };
>> >
>> >
>> >         Form form = new Form("form");
>> >
>> >         form.add(modalWindow);
>> >         form.add(addButton);
>> >
>> >
>> The code looks OK to me. It shouldn't submit twice.
>> Please create a quickstart app that we can debug and attach it to JIRA.
>>
>>
>> >
>> >
>> > Thank you.
>> >
>> > --
>> >
>> > Ajayi S . Yinka
>> > +2348022684477
>> >
>>
>
>
>
> --
>
> Ajayi S . Yinka
> +2348022684477
>
>


-- 

Ajayi S . Yinka
+2348022684477

Re: clicking Ajax SubmitLink button called submit method twice

Posted by Ajayi Yinka <ia...@googlemail.com>.
Thank you Martin,

I change the implementation to below and its working fine now.

Add this to Html
<div wicket:id="panel"> </div>

change the add(form) to

add(new Panel("panel", object));

the modal window is implemented in panel

For the purpose of checking, I will create the quickstart how it was
implemented before as you requested.



On 21 September 2014 16:45, Martin Grigorov <mg...@apache.org> wrote:

> Hi,
>
> On Sun, Sep 21, 2014 at 10:48 AM, Ajayi Yinka <ia...@googlemail.com>
> wrote:
>
> > Hello everyone,
> >
> > submit method called more than one time trigering two modalWindows to
> open
> > at the same time.
> >
> > See snippet below. If I put the just only modal.show(target) in the
> > onsubmit method and others in Page constuctor, the problem still persist.
> >
> > I am using version 6.16.
> >
> > What am I doing wrong here? I will appreciate better way of doing this.
> >
> >
> > AjaxSubmitLink addButton = new AjaxSubmitLink("addButton") {
> >             @Override
> >             public void onSubmit(AjaxRequestTarget target,  Form form) {
> >                 // your stuff
> >                 if (target != null) {
> >
>
> target should be always non-null here
>
>
> >                     Object obj= new Object();
> >                     Object Panel panel = new
> > ObjectPanel(modalWindow.getContentId(), object);
> >                     modalWindow.setContent(panel);
> >                     modalWindow.setTitle("New Object");
> >                     //modalWindow.setEnabled(true);
> >                     //modalWindow.showUnloadConfirmation(true);
> >
> >                         modalWindow.show(target);
> >                         System.out.println("\n\nI am called
> > 1111111111111111111111111111111" + target.getLastFocusedElementId());
> >
> >                 }
> >             }
> >         };
> >
> >
> >         Form form = new Form("form");
> >
> >         form.add(modalWindow);
> >         form.add(addButton);
> >
> >
> The code looks OK to me. It shouldn't submit twice.
> Please create a quickstart app that we can debug and attach it to JIRA.
>
>
> >
> >
> > Thank you.
> >
> > --
> >
> > Ajayi S . Yinka
> > +2348022684477
> >
>



-- 

Ajayi S . Yinka
+2348022684477

Re: clicking Ajax SubmitLink button called submit method twice

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

On Sun, Sep 21, 2014 at 10:48 AM, Ajayi Yinka <ia...@googlemail.com>
wrote:

> Hello everyone,
>
> submit method called more than one time trigering two modalWindows to open
> at the same time.
>
> See snippet below. If I put the just only modal.show(target) in the
> onsubmit method and others in Page constuctor, the problem still persist.
>
> I am using version 6.16.
>
> What am I doing wrong here? I will appreciate better way of doing this.
>
>
> AjaxSubmitLink addButton = new AjaxSubmitLink("addButton") {
>             @Override
>             public void onSubmit(AjaxRequestTarget target,  Form form) {
>                 // your stuff
>                 if (target != null) {
>

target should be always non-null here


>                     Object obj= new Object();
>                     Object Panel panel = new
> ObjectPanel(modalWindow.getContentId(), object);
>                     modalWindow.setContent(panel);
>                     modalWindow.setTitle("New Object");
>                     //modalWindow.setEnabled(true);
>                     //modalWindow.showUnloadConfirmation(true);
>
>                         modalWindow.show(target);
>                         System.out.println("\n\nI am called
> 1111111111111111111111111111111" + target.getLastFocusedElementId());
>
>                 }
>             }
>         };
>
>
>         Form form = new Form("form");
>
>         form.add(modalWindow);
>         form.add(addButton);
>
>
The code looks OK to me. It shouldn't submit twice.
Please create a quickstart app that we can debug and attach it to JIRA.


>
>
> Thank you.
>
> --
>
> Ajayi S . Yinka
> +2348022684477
>