Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 4.0

...

Since Wicket Ajax now register DOM events (like click, change, ...) instead of using inline attributes like onclick, onchange, ... there is no more a script to decorate. Instead the new implementation provides points to listen to:

  • before handler - executed before the data for the Ajax call is calculated. Even before the preconditions.
  • precondition - if it returns false then the Ajax call (and all handlers below) is not executed at all
  • beforeSend handler - executed before the actual execution of the Ajax call.
  • after handler - if the Ajax call is asynchronous then it is executed right after its firing. If it is synchronous then it is executed after the complete handler
  • success handler - executed on successful return of the Ajax call
  • failure handler - executed on unsuccessful return of the Ajax call
  • complete handler - executed at the very end. After either the success or failure handlers.

To use it do:
AnyAjaxComponent/AnyAjaxBehavior.java:

...

IAjaxCallListener's can be used to listen for the lifecycle of an Ajax call for a specific component.
If the user application needs to listen for all Ajax calls then it may subscribe to the following topics:

  • /ajax/call/before
  • /ajax/call/precondition
  • /ajax/call/beforeSend
  • /ajax/call/after
  • /ajax/call/success
  • /ajax/call/failure
  • /ajax/call/complete

Those replaces the old Wicket.Ajax.(registerPreCallHandler|registerPostCallHandler|registerFailureHandler) methods and uses publish/subscribe mechanism.

...

There are two additional topics which are used to notify the subscribers when an HTML element is about to be removed and when a new one is added to the document:

  • /dom/node/removing - receives as parameters the jQuery.Event and the HTMLElement that will be removed
  • /dom/node/added - receives as parameters the jQuery.Event and the HTMLElement that has just been added

Automatically migrated attributes.

Some of the attributes are available from the previous versions of Wicket as an overridable methods in AbstractDefaultAjaxBehavior. These methods are marked as deprecated and will be removed in Wicket 7.0 and for now Wicket automatically translates them into AjaxRequestAttributes.
These methods are:

  • org.apache.wicket.ajax.AbstractDefaultAjaxBehavior#getPreconditionScript()
  • org.apache.wicket.ajax.AbstractDefaultAjaxBehavior#getSuccessScript()
  • org.apache.wicket.ajax.AbstractDefaultAjaxBehavior#getFailureScript()
  • org.apache.wicket.ajax.AbstractDefaultAjaxBehavior#getChannel()

It is recommended to override org.apache.wicket.ajax.AbstractDefaultAjaxBehavior#updateAjaxAttributes(AjaxRequestAttributes) and configure those directly in the passed 'attributes'.

...