You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Chris <ch...@gmx.at> on 2015/05/30 19:44:33 UTC

link with confirm dialog

Hi all,

how can I change the code so that the confirm-dialog is called when the #onClick method is executed and not at constructor-time?
I would like to change the dialog text based on some runtime variable.

Thanks, Chris



 Link link = new AjaxFallbackLink("link") {

            @Override
            public void onClick(AjaxRequestTarget target) {
                setResponsePage(new Page());
            }

            @Override
            protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
                super.updateAjaxAttributes(attributes);
				AjaxCallListener ajaxCallListener = new AjaxCallListener();
                    ajaxCallListener.onPrecondition("return confirm('...');");
                    attributes.getAjaxCallListeners().add(ajaxCallListener);
                }
            }
        };
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: link with confirm dialog

Posted by Chris <ch...@gmx.at>.
Thanks for your answer,

Chris


> Am 31.05.2015 um 22:48 schrieb Martin Grigorov <mg...@apache.org>:
> 
> Hi,
> 
> 'confirm' is a JavaScript method.
> It is executed *before* the Ajax call that would lead to execution of
> AjaxFallbackLink's onClick().
> If 'confirm' returns false then the Ajax call won't be made at all.
> 
> To accomplish what you need you have to introduce a step in the middle.
> When the user clicks on the Ajax link you have to open a dialog/modal
> window with your question and buttons OK/Cancel. If OK is clicked then go
> to page Page, otherwise do nothing.
> 
> Martin Grigorov
> Wicket Training and Consulting
> https://twitter.com/mtgrigorov
> 
> On Sat, May 30, 2015 at 8:44 PM, Chris <ch...@gmx.at> wrote:
> 
>> Hi all,
>> 
>> how can I change the code so that the confirm-dialog is called when the
>> #onClick method is executed and not at constructor-time?
>> I would like to change the dialog text based on some runtime variable.
>> 
>> Thanks, Chris
>> 
>> 
>> 
>> Link link = new AjaxFallbackLink("link") {
>> 
>>            @Override
>>            public void onClick(AjaxRequestTarget target) {
>>                setResponsePage(new Page());
>>            }
>> 
>>            @Override
>>            protected void updateAjaxAttributes(AjaxRequestAttributes
>> attributes) {
>>                super.updateAjaxAttributes(attributes);
>>                                AjaxCallListener ajaxCallListener = new
>> AjaxCallListener();
>>                    ajaxCallListener.onPrecondition("return
>> confirm('...');");
>> 
>> attributes.getAjaxCallListeners().add(ajaxCallListener);
>>                }
>>            }
>>        };
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>> 
>> 


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


Re: link with confirm dialog

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

'confirm' is a JavaScript method.
It is executed *before* the Ajax call that would lead to execution of
AjaxFallbackLink's onClick().
If 'confirm' returns false then the Ajax call won't be made at all.

To accomplish what you need you have to introduce a step in the middle.
When the user clicks on the Ajax link you have to open a dialog/modal
window with your question and buttons OK/Cancel. If OK is clicked then go
to page Page, otherwise do nothing.

Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov

On Sat, May 30, 2015 at 8:44 PM, Chris <ch...@gmx.at> wrote:

> Hi all,
>
> how can I change the code so that the confirm-dialog is called when the
> #onClick method is executed and not at constructor-time?
> I would like to change the dialog text based on some runtime variable.
>
> Thanks, Chris
>
>
>
>  Link link = new AjaxFallbackLink("link") {
>
>             @Override
>             public void onClick(AjaxRequestTarget target) {
>                 setResponsePage(new Page());
>             }
>
>             @Override
>             protected void updateAjaxAttributes(AjaxRequestAttributes
> attributes) {
>                 super.updateAjaxAttributes(attributes);
>                                 AjaxCallListener ajaxCallListener = new
> AjaxCallListener();
>                     ajaxCallListener.onPrecondition("return
> confirm('...');");
>
> attributes.getAjaxCallListeners().add(ajaxCallListener);
>                 }
>             }
>         };
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>