Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Add notes about IAjaxCallListener

...

Code Block
  getJavaScriptLibrarySettings().setBackingLibraryReference(AnotherVersionOfJQueryReference.class);

Migration steps

o.a.w.ajax.IAjaxCallDecorator is replaced with o.a.w.ajax.attributes.IAjaxCallListener.

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 fire of the Ajax call
  • after handler - executed after the fire of the Ajax call but before it returns (if the Ajax call is asynchronous)
  • success handler - executed on successful return of the Ajax call
  • failure handler - executed on unsuccessful return of the Ajax call
  • complete handler - executed on both successful and unsuccessful return

To use it do:
AnyAjaxComponent/AnyAjaxBehavior.java:

Code Block

  protected void updateAjaxAttributes(AjaxRequestAttributes attributes)
  {
      super.updateAjaxAttributes(AjaxRequestAttributes attributes);

      AjaxCallListener myAjaxCallListener = new AjaxCallListener() {

        @Override public CharSequence getBeforeHandler() { return "alert('I\'m executed before the firing of the Ajax call')"; }
      };
      attributes.getAjaxCallListeners().add(myAjaxCallListener);
  }

An Ajax request can have 0 or more IAjaxCallListener's.
o.a.w.ajax.attributes.AjaxCallListener is an adapter of IAjaxCallListener that implements all methods with noop bodies. If the body returns null or empty string then it is discarded.