You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Nick Pratt <nb...@gmail.com> on 2012/11/15 18:14:20 UTC

Asking for user confirmation - Wicket 6

The examples for asking for user confirmation before destructive events
detailed here:
https://cwiki.apache.org/WICKET/getting-user-confirmation.html dont seem to
be applicable anymore (Wicket 6).

The JS examples listed result in an embedded onclick handler being attached
to the element, and the bound handlers (for an AjaxLink) are invoked
regardless of the return code of the embedded handler - so something like
this:

deleteUserLink.add( new JavascriptEventConfirmation( "onclick", "Are you
sure?" ) );

has no effect since the bound onClick handler of the AjaxLink seem to fire
regardless of the return value of the inline JS.

Whats the best way to achieve such confirmation in Wicket 6?

N

Re: Asking for user confirmation - Wicket 6

Posted by Nick Pratt <nb...@gmail.com>.
Thanks - I noticed that also - the wiki entry has the correct code.

Nick


On Fri, Nov 16, 2012 at 4:26 AM, Dieter Tremel <tr...@tremel-computer.de>wrote:

> Am 15.11.2012 18:47, schrieb Sven Meier:
> > ajaxCallListener.onPrecondition("return confirm('are you sure'?);");
>
> I made a test and found the small Typo, should be:
> ajaxCallListener.onPrecondition("return confirm('are you sure?');");
>
> Dieter
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Asking for user confirmation - Wicket 6

Posted by Dieter Tremel <tr...@tremel-computer.de>.
Am 15.11.2012 18:47, schrieb Sven Meier:
> ajaxCallListener.onPrecondition("return confirm('are you sure'?);");

I made a test and found the small Typo, should be:
ajaxCallListener.onPrecondition("return confirm('are you sure?');");

Dieter

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


Re: Asking for user confirmation - Wicket 6

Posted by Nick Pratt <nb...@gmail.com>.
Thanks Sven.

I updated the Wiki entry.

N


On Thu, Nov 15, 2012 at 12:47 PM, Sven Meier <sv...@meiers.net> wrote:

> Overwrite #updateAjaxAttributes in your behavior or AjaxLink:
>
>             @Override
>             protected void updateAjaxAttributes(**AjaxRequestAttributes
> attributes)
>             {
>                 super.updateAjaxAttributes(**attributes);
>
>                 AjaxCallListener ajaxCallListener = new AjaxCallListener();
>                 ajaxCallListener.**onPrecondition("return confirm('are
> you sure'?);");
> attributes.**getAjaxCallListeners().add(**ajaxCallListener);
>             }
>
> Sven
>
>
> On 11/15/2012 06:14 PM, Nick Pratt wrote:
>
>> The examples for asking for user confirmation before destructive events
>> detailed here:
>> https://cwiki.apache.org/**WICKET/getting-user-**confirmation.html<https://cwiki.apache.org/WICKET/getting-user-confirmation.html>dont seem to
>> be applicable anymore (Wicket 6).
>>
>> The JS examples listed result in an embedded onclick handler being
>> attached
>> to the element, and the bound handlers (for an AjaxLink) are invoked
>> regardless of the return code of the embedded handler - so something like
>> this:
>>
>> deleteUserLink.add( new JavascriptEventConfirmation( "onclick", "Are you
>> sure?" ) );
>>
>> has no effect since the bound onClick handler of the AjaxLink seem to fire
>> regardless of the return value of the inline JS.
>>
>> Whats the best way to achieve such confirmation in Wicket 6?
>>
>> N
>>
>>
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: users-unsubscribe@wicket.**apache.org<us...@wicket.apache.org>
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Asking for user confirmation - Wicket 6

Posted by Sven Meier <sv...@meiers.net>.
Overwrite #updateAjaxAttributes in your behavior or AjaxLink:

             @Override
             protected void updateAjaxAttributes(AjaxRequestAttributes 
attributes)
             {
                 super.updateAjaxAttributes(attributes);

                 AjaxCallListener ajaxCallListener = new AjaxCallListener();
                 ajaxCallListener.onPrecondition("return confirm('are 
you sure'?);");
attributes.getAjaxCallListeners().add(ajaxCallListener);
             }

Sven


On 11/15/2012 06:14 PM, Nick Pratt wrote:
> The examples for asking for user confirmation before destructive events
> detailed here:
> https://cwiki.apache.org/WICKET/getting-user-confirmation.html dont seem to
> be applicable anymore (Wicket 6).
>
> The JS examples listed result in an embedded onclick handler being attached
> to the element, and the bound handlers (for an AjaxLink) are invoked
> regardless of the return code of the embedded handler - so something like
> this:
>
> deleteUserLink.add( new JavascriptEventConfirmation( "onclick", "Are you
> sure?" ) );
>
> has no effect since the bound onClick handler of the AjaxLink seem to fire
> regardless of the return value of the inline JS.
>
> Whats the best way to achieve such confirmation in Wicket 6?
>
> N
>


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