Skip to content

Instantly share code, notes, and snippets.

@cristobal
Last active December 24, 2015 12:19
Show Gist options
  • Select an option

  • Save cristobal/6797454 to your computer and use it in GitHub Desktop.

Select an option

Save cristobal/6797454 to your computer and use it in GitHub Desktop.
Custom Wicket Event Message Example
class CustomContainer extends WebMarkupContainer {
public CustomContainer(String id) {
super(id);
}
@override
public void onBeforeRender() {
// Some form do forward message passing for
// All Pages/Componets implements IEventSource
final Form<Void> form = new Form<Void>("formId") {
@Override
protected void onSubmit() {
super.onSubmit();
send(getApplication(), Broadcast.BREADTH, this.getParent()); // forward by using send
}
};
}
}
class CustomPage extends WebPage {
protected static Logger LOG = LoggerFactory.getLogger(CustomPage.class);
public CustomPage() {
}
// Our EventSink, alle pages, components implements IEventSink
@Override
public void onEvent(IEvent<?> event) {
if ((event.getPayload()) instanceof CustomContainer) {
LOG.debug("We received an event from the CustomContainer with id: {}", ((CustomContainer) (event.getPayload).getId()) );
// Stop bubbling the event
event.stop();
}
else {
// we where not meant to receive this event continue bubbling
super.onEvent(event);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment