Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: removed spaces at beginning of code lines so it has a better chance of fitting on the page and not requiring a scrollbar

...

AnyAjaxComponent/AnyAjaxBehavior.java:

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

      attributes.[set some attribute]();
  }

The available attributes are:

...

To use it do:
AnyAjaxComponent/AnyAjaxBehavior.java:

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

      AjaxCallListener myAjaxCallListener = new AjaxCallListener() {

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

There are also handy methods like onBefore(CharSequence), onComplete(CharSequence), ... but they do not provide access to the component which is bound with the Ajax behavior.

...

Example (JavaScript):

Code Block
    Wicket.Event.subscribe('/ajax/call/failure', function(jqEvent, attributes, jqXHR, errorThrown, textStatus) {
      // do something when an Ajax call fails
    });

All global listeners receive the same arguments as the respective IAjaxCallListener handler plus jQuery.Event that is passed by the PubSub system. This event is not the event that caused the Ajax call. The one that caused the Ajax call is 'attrs.event'.

...

The global listeners receive the same parameters prepended by jqEvent. This is the event triggered by jQuery. See section Global Ajax call listeners above.

...