you can click on it and the event listener can delay the actual Ajax call
as much as it wants (Wicket's AjaxChannel.QUEUE does exactly this).

E.g. click two times on the link, the first click fires Ajax call (the
second click waits), its response removes the link from the DOM (or
replaces it), then the second click event will be prevented because its
event.target is no more in the DOM


Martin Grigorov
Wicket Training and Consulting


On Thu, Feb 6, 2014 at 3:13 PM, Richter, Marvin <
[email protected]> wrote:

> That is the point I don't get ... how can an element doesn't exist in DOM
> but I can click on it?
>
> Marvin Richter
>
>
> -----Original Message-----
> From: Martin Grigorov [mailto:[email protected]]
> Sent: Thursday, February 06, 2014 3:05 PM
> To: [email protected]
> Subject: Re: Precondition Check
>
> Hi,
>
> I see you don't have custom AjaxRequestAttributes, so no custom
> preconditions.
> Wicket has just one default precondition - it will execute the Ajax call
> only if the related HTML element (the link) is in the current document.
>
>
> https://github.com/apache/wicket/blob/master/wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-ajax-jquery.js?source=c#L508
>
> Put a breakpoint in Dev Tools/Firebug and see why the link is not in the
> document.
>
> Martin Grigorov
> Wicket Training and Consulting
>
>
> On Thu, Feb 6, 2014 at 2:50 PM, Richter, Marvin <
> [email protected]> wrote:
>
> > Args ... I already had this problem some time ago but I can't remember
> > what it was exactly.
> >
> > Wicket Ajax Debug:
> > INFO: Ajax request stopped because of precondition check, url:
> > ./admin?1-5.IBehaviorListener.1-configTypes-panel-dialog-footer-button
> > s-0-button
> >
> > I have two different Panels with almost the same functionality ...
> > creating a new Object and persist it. One is working fine but the
> > other one not.
> >
> > Works:
> > private Component save(final Form<ConfigType> form) {
> >         return new AjaxSubmitLink(BUTTON_MARKUP_ID, form) {
> >
> >                     @Override
> >                     protected void onSubmit(AjaxRequestTarget target,
> > Form<?> f) {
> >                         Logger log =
> > LoggerFactory.getLogger(EditConfigTypeDialog.class);
> >                         ConfigManager cm =
> > EjbSupportImpl.getInstance().getConfigManager();
> >                         ConfigType configType = form.getModelObject();
> >                         if (configType.getId() != null) {
> >                             try {
> >                                 ConfigType updated =
> > cm.updateConfigType(configType);
> >                                 form.success("Successfully updated the
> > ConfigType.");
> >                                 form.setModelObject(updated);
> >                             } catch (CcaException ex) {
> >                                 form.error("Failed to update
> ConfigType");
> >                                 log.error("Failed to update
> > ConfigType", ex);
> >                             }
> >                         } else {
> >                             try {
> >                                 ConfigType created =
> > cm.addConfigType(configType);
> >                                 form.success("Successfully created the
> > ConfigType.");
> >                                 form.setModelObject(created);
> >                             } catch (CcaException ex) {
> >                                 form.error("Failed to create
> ConfigType");
> >                                 log.error("Failed to create
> > ConfigType", ex);
> >                             }
> >                         }
> >                         target.add(form);
> >                     }
> >
> >                     @Override
> >                     protected void onError(AjaxRequestTarget target,
> > Form<?> form) {
> >                         target.add(form);
> >                     }
> >
> >                     @Override
> >                     public void onComponentTagBody(MarkupStream
> > markupStream, ComponentTag openTag) {
> >                         replaceComponentTagBody(markupStream, openTag,
> > "Save");
> >                     }
> >                 }.add(new ButtonBehavior(Buttons.Type.Primary));
> >     }
> >
> > Doesn't work:
> > private Component save(final Form<ConfigKey> form) {
> >         return new AjaxSubmitLink(BUTTON_MARKUP_ID, form) {
> >
> >                     @Override
> >                     protected void onSubmit(AjaxRequestTarget target,
> > Form<?> f) {
> >                         Logger log =
> > LoggerFactory.getLogger(EditConfigKeyDialog.class);
> >                         ConfigManager cm =
> > EjbSupportImpl.getInstance().getConfigManager();
> >                         ConfigKey configKey = form.getModelObject();
> >                         if (configKey.getId() != null) {
> >                             try {
> >                                 ConfigKey updated =
> > cm.updateConfigKey(configKey);
> >                                 form.success("Successfully updated the
> > ConfigKey");
> >                                 form.setModelObject(updated);
> >                             } catch (CcaException ex) {
> >                                 form.error("Failed to update ConfigKey");
> >                                 log.error("Failed to update
> > ConfigKey", ex);
> >                             }
> >                         } else {
> >                             try {
> >                                 ConfigKey created =
> > cm.addConfigKey(configKey);
> >                                 form.success("Successfully created the
> > ConfigKey");
> >                                 form.setModelObject(created);
> >                             } catch (CcaException ex) {
> >                                 form.error("Failed to create ConfigKey");
> >                                 log.error("Failed to create
> > ConfigKey", ex);
> >                             }
> >                         }
> >                         target.add(form);
> >                     }
> >
> >                     @Override
> >                     protected void onError(AjaxRequestTarget target,
> > Form<?> form) {
> >                         target.add(form);
> >                     }
> >
> >                     @Override
> >                     public void onComponentTagBody(MarkupStream
> > markupStream, ComponentTag openTag) {
> >                         replaceComponentTagBody(markupStream, openTag,
> > "Save");
> >                     }
> >                 }.add(new ButtonBehavior(Buttons.Type.Primary));
> >     }
> >
> > I don't see a big difference why the other wouldn't work. You?
> >
> >
> > Marvin Richter
> > Software Developer
> > T  +49 (0) 30 69 538 1099
> > M  +49 (0) 174 744 4991
> > [email protected]<mailto:[email protected]
> > >
> >
> > JESTA DIGITAL GmbH   Karl-Liebknecht-Str. 32   10178 Berlin, Germany
> > Gesellschaft mit beschränkter Haftung mit Sitz in Berlin HRB Nr. 97990
> > Amtsgericht Charlottenburg
> > Geschäftsführer: Markus Peuler
> >
> >
>

Reply via email to