the problem is quite simple yet maybe not resolvable? Atleast for me :/
Situation: Let's say I have a dynamic Page System where the Server provides additional copies of self containing GWT Modules. Meaning a main GWT instance on the client side is supposed to manage the new incoming GWT Scripts, which are simply added by the main instance itself using Tags. Now the main GWT instance needs to communicate with the newly created script instances in the most easiest (GWT internally) way possible.
So what is out of the question: Writing stupid JSNI Wrappers on both sides, if not absolutely required.
Soltuions I came up with were: Make a module both use, including a common interface, example:
package com.whatever.interfaces;
public interface Communication {
void showMessage(String message);
}
So both would now inherit this module and know of the definition. The main client would now load the dynamic JS and register an implementation of Communication and the dynamic one would go and use it. I tried storing references on $wnd and on elements using setPropertyObject. On $wnd they are null, which maybe/probably related to the the GWT Iframing? For the property on the RootPanel element for example, ClassCastException would be raised.
Is there any good way to encounter this? Another idea I have is using JSNI for calling the interface as an implementation on the bridge module, but I'm not sure if this a good way.
Your help is appreciated, thanks.
EDIT: Well I have pretty much come to the conclusion that this is not possible whatsoever. Even though you might have used same interfaces somewhere, they will be very own instantiations of it, for different modules compiled, even if using the same module as a common ground. The approach using JSNI certainly is somewhat possible, but not without mapping all attributes to real JS Objects and remapping them back. Meaning you can't pass complex Java Objects around like you probably would be used to. My conclusion would be, using CodeGenerators you could build the JSNI Wrappers automatically and the remappers, for both modules, but this is too much of a hassle for me.
I'm still open if someone comes up with a better idea, but I just want to provide some inside on my findings, so others can benefit of my wasted time ;)