you can also use behavior AbstractDefaultAjaxBehavior which has updateAjaxAttributes(AjaxRequestAttributes attributes), so you can share confirmation code among different components.
Hi,

On Thu, Oct 30, 2014 at 11:57 PM, Garret Wilson <gar...@globalmentor.com>
wrote:

Andrea, thanks for jolting my brain; I was a little sleepy this morning.

I was using a subclass of AjaxLink that added confirmation JavaScript as I
outlined below. My original HTML was:

     <button wicket:id="foo" type="submit">

The root of the problem is that Wicket kept turning that into:

     <button wicket:id="foo" type="button" id="foo7">

Thus even though I got a confirmation dialog, the FileUpload was never
being populated because the form was never being submitted.

It turns out that apparently I have to use a subclass of AjaxSubmitLink
rather than AjaxLink if I want the form to actually be submitted, even
though I specified type="submit" in the HTML. So my immediate problem is
solved.

On a higher level, though, it means that I now have to go create a
ConfirmationAjaxSubmitLink along with my ConfirmationAjaxLink. I would have
thought/hoped that things like "submission" and "confirmation" were
something that could be injected to various components using behaviors
rather that subclassing all over the place.

There is a way to provide a global #updateAjaxAttributes() that is called
for each and every Ajax
behavior: 
org.apache.wicket.ajax.AjaxRequestTarget.IListener#updateAjaxAttributes

With
https://git-wip-us.apache.org/repos/asf?p=wicket.git;a=commit;h=d1caec5e
I've improved it so there is no need to cast it
to AbstractDefaultAjaxBehavior in the application code. You can use
AbstractDefaultAjaxBehavior#getComponent() to check whether you should
contribute to the ajax attributes or nor.




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

Reply via email to