Inter module communication using event bus in mvp4g gwt

414 views Asked by At

Our web application is based on mvp4g framework. To explain my situation I will be using the following notations:

A, B              - two different gwt modules
presenterA, viewA - presenter and view pair in module A
            viewA contains an iframe and a button along with other UI components
presenterB, viewB - presenter and view pair in module B
eventBusA         - an eventBus in A with event handler in presenterA
eventBusB         - an eventBus in B with event handler in presenterB

Flow of application starts with loading of A. viewA is displayed and contains a button and an iframe on click of which module B is loaded inside the iframe by calling a URL and simultaneously hides the viewA from active viewing. Thus it is still active in the background. B is a seperate module(no child parent relationship between A and B). It loads viewB and after a button click in viewB I want to go again to an event in eventBusA since I want to change the status of viewA from hidden to visible. But eventBusA is not accessible from either presenterB or eventBusB.

I have tried the following which did not work:

  1. Created and event in eventBusB to respond to click in viewB via presenterB. Added presenterA as the handler.
  2. On the same event added moduleToLoad with module A as the target. It requires A to be declared as the child module.
  3. Thought about javascript API using GWT-Exporter project.
1

There are 1 answers

0
El Hoss On

Your problem is, that module B has to send a push notification to module A. There is no ready solution for that.

Best solution will be, to send an URL to start Module A again and use the Place pattern to restore the application state of module A.

Therefore module A has to send a token (history token) to module B. Module B has to save the token and if you module B will give back the control to module A, it has to call the url for module A and use the token as a #-parameter. Take a look at the history doumentation of mvp4g.