Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

There is an example in wicket-examples which demonstrates the usage of this.

IEventDispatcher

M4 also introduces IEventDispatcher. Applications can register custom event dispatchers in frameworksettings; the dispatchers can be used to build custom event delivery mechanisms. For example a custom IEventDispatcher mechanism can route events to annotated methods, eg

Code Block

public class MyComponent extends Component {
    @OnEvent
    private void onUserAdded(UserAddedEvent event) {...}
}

where UserAddedEvent is the event payload object.

The default Component#onEvent() method will be called even if custom dispatchers are registered.

Default ajax event

M4 also introduces a default event raised whenever wicket begins to create an ajax response. The payload of the event is the AjaxRequestTarget used for event. Sample implementation:

Code Block

// component that always adds itself to the ajax response
public class MyComponent extends Component {
    public void onEvent(IEvent event) {
        if (event.getPayload() instanceof AjaxRequestTarget) {
            ((AjaxRequestTarget)event.getPayload()).add(this);
         }
    }
}

(M4) Header render sequence inverted

...