You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Eyal Golan <eg...@gmail.com> on 2008/06/03 11:01:41 UTC

Add onClick to an AjaxButton

Hello all,
We have a StyledAjaxButton that extends AjaxButton.
We want to add a confirmation when clicking.

We added this:
                @Override
                protected String getOnClickScript() {
                    String warning =
LocalizationHelper.getMessage("page.confirmation.message", DELETE_TICKETS);
                    return "if (!window.confirm('"+warning+"')) return
false;";
                }

Now, in a normal Button it works.
But in the AjaxButton it does not.
I checked the AjaxButton and saw that an AjaxFormSubmitBehavior is added to
it with an onClick.
How can I add another behavior like this?
Or how can I tackle this problem?

Thanks

-- 
Eyal Golan
egolan74@gmail.com

Visit: http://jvdrums.sourceforge.net/
LinkedIn: http://www.linkedin.com/in/egolan74

Re: Add onClick to an AjaxButton

Posted by Eyal Golan <eg...@gmail.com>.
No,
We're on 1.3.3
Nice though :) when we move to 1.4, I'll try to remember using it as well.

Thanks

On Wed, Jun 4, 2008 at 6:15 AM, Igor Vaynberg <ig...@gmail.com>
wrote:

> are you on 1.4, i checked in a change that will allow ajaxbutton to
> utilize getonclickscript() within the ajax handler it generates...
>
> -igor
>
> On Tue, Jun 3, 2008 at 2:47 AM, Eyal Golan <eg...@gmail.com> wrote:
> > One more thing.
> > If I understand correctly, AjaxButton should override the
> getOnClickScript()
> > method, return null and be declared final.
> >
> > What to you people think?
> >
> > --
> > Eyal Golan
> > egolan74@gmail.com
> >
> > Visit: http://jvdrums.sourceforge.net/
> > LinkedIn: http://www.linkedin.com/in/egolan74
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
Eyal Golan
egolan74@gmail.com

Visit: http://jvdrums.sourceforge.net/
LinkedIn: http://www.linkedin.com/in/egolan74

Re: Add onClick to an AjaxButton

Posted by Igor Vaynberg <ig...@gmail.com>.
are you on 1.4, i checked in a change that will allow ajaxbutton to
utilize getonclickscript() within the ajax handler it generates...

-igor

On Tue, Jun 3, 2008 at 2:47 AM, Eyal Golan <eg...@gmail.com> wrote:
> One more thing.
> If I understand correctly, AjaxButton should override the getOnClickScript()
> method, return null and be declared final.
>
> What to you people think?
>
> --
> Eyal Golan
> egolan74@gmail.com
>
> Visit: http://jvdrums.sourceforge.net/
> LinkedIn: http://www.linkedin.com/in/egolan74
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


RE: Add onClick to an AjaxButton

Posted by Brill Pappin <br...@pappin.ca>.
Declare nothing final unless trying to solve a particular problem.

...m2c
- Brill Pappin 

-----Original Message-----
From: Eyal Golan [mailto:egolan74@gmail.com] 
Sent: Tuesday, June 03, 2008 5:47 AM
To: users@wicket.apache.org
Subject: Re: Add onClick to an AjaxButton

One more thing.
If I understand correctly, AjaxButton should override the getOnClickScript()
method, return null and be declared final.

What to you people think?

--
Eyal Golan
egolan74@gmail.com

Visit: http://jvdrums.sourceforge.net/
LinkedIn: http://www.linkedin.com/in/egolan74


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Add onClick to an AjaxButton

Posted by Eyal Golan <eg...@gmail.com>.
One more thing.
If I understand correctly, AjaxButton should override the getOnClickScript()
method, return null and be declared final.

What to you people think?

-- 
Eyal Golan
egolan74@gmail.com

Visit: http://jvdrums.sourceforge.net/
LinkedIn: http://www.linkedin.com/in/egolan74

Re: Add onClick to an AjaxButton

Posted by Eyal Golan <eg...@gmail.com>.
Thanks Nino, first phase is done. I get the error message.
My code is like this:
In the AjaxButton:
                @Override
                protected void onSubmit(AjaxRequestTarget target, Form form)
{
                    String warning =
LocalizationHelper.getMessage("page.confirmation.message");
                    String confirmJS = "window.confirm('"+warning+"')";
                    target.prependJavascript(confirmJS);
                    target.addComponent(resultLabel);
                    try {
                        getTicketManager().deleteAllTickets();
                        succeeded = true;

setResult(LocalizationHelper.getMessage("page.admin.successMessage"));
                    } catch (Throwable t)  {
                        succeeded = false;

setResult(LocalizationHelper.getMessage("page.admin.failureMessage"));
                    }
                }
My problem, of course, is that I still delete the tickets (in
getTicketManager().deleteAllTickets();).

How can I check the script's result and according to this decide what to do?

On Tue, Jun 3, 2008 at 12:18 PM, Nino Saturnino Martinez Vazquez Wael <
nino.martinez@jayway.dk> wrote:

> hmm, just add it to the ajaxrequesttarget instead...
>
> target.prependJavascript(javascript) ? Not sure if this does the trick
> though.
>
> Eyal Golan wrote:
>
>> Hello all,
>> We have a StyledAjaxButton that extends AjaxButton.
>> We want to add a confirmation when clicking.
>>
>> We added this:
>>                @Override
>>                protected String getOnClickScript() {
>>                    String warning =
>> LocalizationHelper.getMessage("page.confirmation.message",
>> DELETE_TICKETS);
>>                    return "if (!window.confirm('"+warning+"')) return
>> false;";
>>                }
>>
>> Now, in a normal Button it works.
>> But in the AjaxButton it does not.
>> I checked the AjaxButton and saw that an AjaxFormSubmitBehavior is added
>> to
>> it with an onClick.
>> How can I add another behavior like this?
>> Or how can I tackle this problem?
>>
>> Thanks
>>
>>
>>
>
> --
> -Wicket for love
>
> Nino Martinez Wael
> Java Specialist @ Jayway DK
> http://www.jayway.dk
> +45 2936 7684
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
Eyal Golan
egolan74@gmail.com

Visit: http://jvdrums.sourceforge.net/
LinkedIn: http://www.linkedin.com/in/egolan74

Re: Add onClick to an AjaxButton

Posted by Nino Saturnino Martinez Vazquez Wael <ni...@jayway.dk>.
hmm, just add it to the ajaxrequesttarget instead...

target.prependJavascript(javascript) ? Not sure if this does the trick 
though.

Eyal Golan wrote:
> Hello all,
> We have a StyledAjaxButton that extends AjaxButton.
> We want to add a confirmation when clicking.
>
> We added this:
>                 @Override
>                 protected String getOnClickScript() {
>                     String warning =
> LocalizationHelper.getMessage("page.confirmation.message", DELETE_TICKETS);
>                     return "if (!window.confirm('"+warning+"')) return
> false;";
>                 }
>
> Now, in a normal Button it works.
> But in the AjaxButton it does not.
> I checked the AjaxButton and saw that an AjaxFormSubmitBehavior is added to
> it with an onClick.
> How can I add another behavior like this?
> Or how can I tackle this problem?
>
> Thanks
>
>   

-- 
-Wicket for love

Nino Martinez Wael
Java Specialist @ Jayway DK
http://www.jayway.dk
+45 2936 7684


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Add onClick to an AjaxButton

Posted by Eyal Golan <eg...@gmail.com>.
Thanks Frank,
It is exactly what I needed.

cheers :)

On Tue, Jun 3, 2008 at 1:00 PM, Frank Bille <fr...@apache.org> wrote:

> I have created a behavior (WIP), which takes care of that:
>
> http://svn2.assembla.com/svn/planningpoker/trunk/planningpoker-wicket/src/main/java/org/planningpoker/wicket/behaviours/ClickConfirmBehavior.java
>
> Frank
>
> On Tue, Jun 3, 2008 at 11:01 AM, Eyal Golan <eg...@gmail.com> wrote:
>
> > Hello all,
> > We have a StyledAjaxButton that extends AjaxButton.
> > We want to add a confirmation when clicking.
> >
> > We added this:
> >                @Override
> >                protected String getOnClickScript() {
> >                    String warning =
> > LocalizationHelper.getMessage("page.confirmation.message",
> DELETE_TICKETS);
> >                    return "if (!window.confirm('"+warning+"')) return
> > false;";
> >                }
> >
> > Now, in a normal Button it works.
> > But in the AjaxButton it does not.
> > I checked the AjaxButton and saw that an AjaxFormSubmitBehavior is added
> to
> > it with an onClick.
> > How can I add another behavior like this?
> > Or how can I tackle this problem?
> >
> > Thanks
> >
> > --
> > Eyal Golan
> > egolan74@gmail.com
> >
> > Visit: http://jvdrums.sourceforge.net/
> > LinkedIn: http://www.linkedin.com/in/egolan74
> >
>



-- 
Eyal Golan
egolan74@gmail.com

Visit: http://jvdrums.sourceforge.net/
LinkedIn: http://www.linkedin.com/in/egolan74

Re: Add onClick to an AjaxButton

Posted by Frank Bille <fr...@apache.org>.
I have created a behavior (WIP), which takes care of that:
http://svn2.assembla.com/svn/planningpoker/trunk/planningpoker-wicket/src/main/java/org/planningpoker/wicket/behaviours/ClickConfirmBehavior.java

Frank

On Tue, Jun 3, 2008 at 11:01 AM, Eyal Golan <eg...@gmail.com> wrote:

> Hello all,
> We have a StyledAjaxButton that extends AjaxButton.
> We want to add a confirmation when clicking.
>
> We added this:
>                @Override
>                protected String getOnClickScript() {
>                    String warning =
> LocalizationHelper.getMessage("page.confirmation.message", DELETE_TICKETS);
>                    return "if (!window.confirm('"+warning+"')) return
> false;";
>                }
>
> Now, in a normal Button it works.
> But in the AjaxButton it does not.
> I checked the AjaxButton and saw that an AjaxFormSubmitBehavior is added to
> it with an onClick.
> How can I add another behavior like this?
> Or how can I tackle this problem?
>
> Thanks
>
> --
> Eyal Golan
> egolan74@gmail.com
>
> Visit: http://jvdrums.sourceforge.net/
> LinkedIn: http://www.linkedin.com/in/egolan74
>