Last active
December 24, 2015 12:19
-
-
Save cristobal/6797454 to your computer and use it in GitHub Desktop.
Custom Wicket Event Message Example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | |
| } | |
| }; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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