Hi,

On Wed, Jul 24, 2013 at 11:54 AM, Marco Di Sabatino Di Diodoro <
[email protected]> wrote:

> Hi all,
>
> I like implement a DropDownChoice with an Confirm Dialog.
> I used an AjaxFormComponentUpdatingBehavior("on change") to intercept the
> change in the DropDownChoice.
> In addition,  the user must first confirm the operation with a dialog
> before changing the value in the DropDownChoice.
>
> To do that I add an AjaxCallListeners:
>
>             @Override
>             protected void updateAjaxAttributes(final
> AjaxRequestAttributes attributes) {
>                 super.updateAjaxAttributes(attributes);
>                 final AjaxCallListener ajaxCallListener = new
> AjaxCallListener() {
>                     private static final long serialVersionUID =
> 7160235486520935153L;
>
>                     @Override
>                     public CharSequence getPrecondition(final Component
> component) {
>                         return "if (confirm('" +
> getString("confirmDelete") + "')) return false;";
>

Try with:             return "if (confirm('" + getString("confirmDelete") +
"')) { attrs.event.preventDefault(); return false;}";

The precondition just stops the Ajax call, but it has no logic to do
anything else.


>                     }
>                 };
>                 attributes.getAjaxCallListeners().add(ajaxCallListener);
>             }});
>
> When I click cancel on the Confirm Dialog, the DropDownChoice changes and
> I can not restore the old value.
> How I understand that the user clicked on Cancel? Is the correct way to
> implement this functionality?
>
> Best Regards
> M
>
> --
> Dott. Marco Di Sabatino Di Diodoro
> Tel. +39 3939065570
>
> Tirasa S.r.l.
> Viale D'Annunzio 267 - 65127 Pescara
> Tel +39 0859116307 / FAX +39 0859111173
> http://www.tirasa.net
>
> Apache Syncope PMC Member
> http://people.apache.org/~mdisabatino/
>
>

Reply via email to