atom feed4 messages in org.apache.wicket.usersAjaxCallListener precondition with us...
FromSent OnAttachments
Thomas HeiglNov 2, 2012 5:25 am 
Martin GrigorovNov 3, 2012 4:42 am 
Sekib_OmazicNov 5, 2012 5:34 am 
Thomas HeiglNov 26, 2012 6:24 am 
Subject:AjaxCallListener precondition with user input
From:Thomas Heigl (tho@umschalt.com)
Date:Nov 2, 2012 5:25:42 am
List:org.apache.wicket.users

Hey all,

I'm currently in the progress of migrating a largish Wicket 1.5 app to Wicket 6.2. The only major problem I could not resolve so far are precondition scripts with user input.

My old code looked like this:

@Override

public CharSequence postDecorateScript(Component component, CharSequence script) { return "jConfirm(function(r) { if (r) {" + script + "}});"; }

The whole script was decorated and the callback only executed if the user pressed OK in a custom confirmation dialog.

In Wicket 6, there are no more script decorators, just listeners that provide hooks into the ajax lifecycle, so I changed my code to this:

@Override

public CharSequence getPrecondition(final Component component) { return "jConfirm(function(r) { if (r) { return true; } }); return false;"; }

The problem is, that the callback function I'm passing to jConfirm is evaluated only when the user makes a selection, but the precondition has to return an output immediately. It would work if we used browser-level confirmation dialogs, but we use a custom jquery dialog for better user experience.

Is there any way to emulate the pre-Wicket 6 behavior using listeners?

Kind regards,

Thomas