I am aware of the getPrecondition() method on IAjaxCallListener that I can
use to prevent the ajax call from happening on the click of a link, button,
etc, but I'm wondering if anything in the wicket framework can prevent the
default altogether.  Let me try to explain with an example of my use case:

final RadioChoice<Hobbit> favorite = new RadioChoice<Hobbit>("favorite",
Model.of(Hobbit.Samwise), Arrays.asList(Hobbit.values()));
favorite.add(new AjaxFormChoiceComponentUpdatingBehavior() {

@Override
protected void onUpdate(AjaxRequestTarget target) {
System.out.println("update has been called.  model is now: " +
favorite.getModelObject());
}

@Override
protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
super.updateAjaxAttributes(attributes);
attributes.getAjaxCallListeners().add(new
AjaxCallListener().onPrecondition("return confirm(\"Did you change your
mind?\");"));
}
});

When I click on one of the radio buttons or its label, I get the
confirmation box.  If I click "OK", it calls the onUpdate() as expected.
 If I click "Cancel", it does not call onUpdate as expected, but what I
would like it to do is revert the state or the RadioChoice before I clicked
it.  Same thing with CheckBoxMultipleChoice.

Is there an easy way in wicket to do this, or do I need to write the custom
javascript to do this myself?  If wicket doesn't do this, should/can it?

-- 
 

IMPORTANT: This e-mail (including any attachments) is intended for the use 
of the individual or entity to which it is addressed and may contain 
information that is classified, private, or confidential. If the reader of 
this message is not the intended recipient, or the employee or agent 
responsible for delivering the message to the intended recipient, you are 
hereby notified that any dissemination, distribution, or copying of this 
communication is prohibited. If you have received this communication in 
error, please notify us immediately by replying to this e-mail. Thank you.

Reply via email to