Hi!

Are you on Wicket 6? If so, here's how I do my confirmation popup for an ajaxlink (should work for ajaxbutton too):

@Override
protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
    String confirmJs = "if (!confirm('Please confirm')) return false;"
    AjaxCallListener listener = new AjaxCallListener();
    listener.onPrecondition(confirmJs);
    attributes.getAjaxCallListeners().add(listener);
}

Of course, in your case, you need to write more complicated javascript to read form values and such. This solution all happens client-side.

You could also do it more server side by preventing default form submit behavior for the ajaxbutton. When the user clicks the button, you show a panel via ajax which asks for confirmation and that second button really sends the form.

Personally, I think I'd go for the first option but it depends on your requirements.

Bertrand



On 21/06/2013 11:36 AM, grignette wrote:
Hi !

I have an issue with a confirm Javascript message. I have a form. When the
user fills the form and  when he tries to submit (AjaxButton), I want to
provide confirm message based on the details filled by user. So the confrm
message may or maynot be present always

I tried to use method getOnClickScript of the Ajax Button. The code in the
getOnClickScript is translate in javascript by wicket on the onload of the
page. So my condition IF is always wrong, because the form is not completed
by the user yet.

I tried to add my condition just before my update, in the submit method with
this :

/target.appendJavaScript("confirm('"+getString("messageConfirm") + "')");/

The message is display just after the update... So to late !

Do you have any idea how I can display this confirm message ?

Thanks for your attention

Gaƫlle





--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Javascript-confirm-with-condition-before-submit-tp4659672.html
Sent from the Users forum mailing list archive at Nabble.com.

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




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

Reply via email to