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 <[email protected]> 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: [email protected] > For additional commands, e-mail: [email protected] > >
