Reputation: 65
I am new with Wicket framework, so I don't know if this is possible. I want that when I click on submit button of form (in Java it's AjaxButton) javascript confirmation dialog pops up, but when I click No, it always calls method onSubmit of this button. What am I doing wrong?
Here my code:
AjaxButton submit;
add(submit = new AjaxButton("ajaxSubmitProduct"){
private static final long serialVersionUID = 1L;
@Override
protected void onComponentTag(ComponentTag tag)
{
super.onComponentTag(tag);
tag.put("onclick", "return confirm('Yes or No?');");
}
@Override
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
target.add(form);
Product p = (Product) form.getModelObject();
DBBroker.save_product(p);
success("You have sucessfully added a new product.");
}
@Override
protected void onError(AjaxRequestTarget target, Form<?> form)
{
target.add(form);
}
});
Upvotes: 2
Views: 2631
Reputation: 20099
Or use a ModalWindow
, if you don't like the Javascript confirm()
look-and-feel (and who does? ;)
See for example here:
http://mysticcoders.com/blog/wicket-ajax-confirmation-modal-window/
Upvotes: 0
Reputation: 5681
You should use an Ajax precondition:
https://cwiki.apache.org/confluence/display/WICKET/Getting+user+confirmation
Upvotes: 2