Should anybody else search for something similar and stumbles across this thread there is a working example at git://github.com/manstis/gwt-plugins.git
On Jul 8, 8:50 pm, manstis <[email protected]> wrote: > Great, success. Thanks. > > So I conclude it is impossible to pass a Java object from one GWT > application client space, through JSNI to another GWT application > client space even with the XS linker option. > > It only appears possible using JavaScriptObject subclasses, i.e. > JScript overlays. > > I might need to bother you again, but I have lots to keep trying > now :) > > Thanks again. > > Mike > > On Jul 5, 6:14 pm, lemaiol <[email protected]> wrote: > > > I do not know really well gwt-exporter, but having a look at your > > question in SO, I have the feeling that you need somehow to pass "real > > JS objects" as parameters. I would try inheriting from > > JavaScritpObject: > > > public class Person extends JavaScriptObject { > > protected Person() { > > // GWT JSO compliance requirement > > } > > > // Use this factory method to create the entities > > public static Person create(String name, int age) { > > Person result = JSObject.create().cast(); // Maybe the name of > > the class "JSObject" used here is wrong (not compiled code!) > > result.setName(name); > > result.setAge(age); > > } > > > public native String getName() /*-{ > > return this.name; // the use of "this" is here required!! > > }-*/; > > > public native void setName(String name) /*-{ > > this.name = name; > > }-*/; > > ... > > > } > > > Hope it helps! > > Berto > > > On Jul 4, 10:27 am, manstis <[email protected]> wrote: > > > > Hi Berto, > > > > I've stuck everything on github; git://github.com/manstis/gwt-plugins.git > > > > plugin - the "plugin" > > > pluginserver - the "framework" > > > plugincommon contains my common model > > > > There's only about 10 files in all; so it's not so ominous. > > > > I thought this would be easier than trying to explain directly - I'm > > > not expecting you to fix anything, it's just so you can see what I > > > have and give some suggestions. > > > > As it stands, I can pass the "common" model class to the "framework", > > > but all attributes are > > > undefined:http://stackoverflow.com/questions/6535303/gwt-gwt-exporter-passing-o... > > > > If you decided to try and run it; plugin and pluginserver WARs can be > > > deployed to Tomcat (I use 6.0) and select the URL for the server > > > portion. > > > > Cheers, > > > > Mike > > > > On Jul 3, 10:14 am,lemaiol<[email protected]> wrote: > > > > > Hi Mike, > > > > > How are the modules loaded and how are they invoked? > > > > > Berto > > > > > On Jun 22, 2:10 pm, manstis <[email protected]> wrote:> Great, > > > > lots to play with :) > > > > > > Before I look into writing my own JSNI bridge, I've still been trying > > > > > to use gwt-exporter, but..... > > > > > > I've three GWT applications:- > > > > > (1) Plugin (inherits "Common") > > > > > (2) Backend (inherits "Common") > > > > > (3) Common > > > > > > "Plugin" > > > > > -------- > > > > > Contains:- > > > > > > ... > > > > > echoButton.addClickHandler(new ClickHandler() { > > > > > > public void onClick(ClickEvent event) { > > > > > //Debugging statements shown --> shows 'callback' is not null > > > > > PluginCallback<String> callback = getPluginCallback(); > > > > > Window.alert("Plugin.onModuleLoad.onClick.callback is " + > > > > > (callback != null ? "not " : "") + "null"); > > > > > > echo(text.getText(), callback); > > > > > } > > > > > > }); > > > > > ... > > > > > > private native void echo(String text, PluginCallback<String> > > > > > callback) /*-{ > > > > > //Debugging statements shown --> shows 'callback' is not null > > > > > alert("Plugin.echo.callback is " + (callback != null ? "not " : > > > > > "") + "null"); > > > > > > $wnd.com.anstis.pluginserver.CommonService.echo(text, callback); > > > > > }-*/; > > > > > > "Backend" > > > > > -------- > > > > > Contains:- > > > > > > public void onModuleLoad() { > > > > > //Use gwt-exporter to generate the JSNI for CommonService.class > > > > > GWT.create(CommonService.class); > > > > > } > > > > > > CommonService is:- > > > > > > @Export > > > > > public class CommonService implements Exportable { > > > > > > private static final EchoServiceAsync echoService = > > > > > GWT.create(EchoService.class); > > > > > > public static void echo(String input, PluginCallback<String> > > > > > callback) { > > > > > //Debugging statements shown --> shows 'callback' is null > > > > > Window.alert("CommonService.echo.callback is " + (callback != > > > > > null ? "not " : "") + "null"); > > > > > try { > > > > > > //The guts of the method, invoke a GWT-RPC call --> RTE, as > > > > > 'callback' is null > > > > > echoService.echo(input, callback); > > > > > > } catch (Exception e) { > > > > > e.fillInStackTrace(); > > > > > e.printStackTrace(System.out); > > > > > Window.alert(e.getMessage()); > > > > > } > > > > > } > > > > > > } > > > > > > "Common" > > > > > -------- > > > > > Simply defines PluginCallback, as follows:- > > > > > > public class PluginCallback<T> implements AsyncCallback<T> { > > > > > public void onFailure(Throwable caught) {} > > > > > public void onSuccess(T result) {} > > > > > } > > > > > > My problem is that the PluginCallback instance is proven to be non- > > > > > null in "Plugin" (both Java and JSNI methods), but is reported as null > > > > > in "Backends" CommonService. > > > > > > Somewhere it is getting munged, but I only pass a Java Object from > > > > > "Plugin" to JSNI (echo) to Java (CommonService) so don't understand > > > > > why it's being nulled?!?! > > > > > > Any ideas (I'll post as a new question if you don't see anything > > > > > wrong, so it gets seen by a new audience as opposed to those just > > > > > following this thread). > > > > > > Thanks, > > > > > > Mike > > > > > > On Jun 21, 7:32 pm,lemaiol<[email protected]> wrote: > > > > > > > Hi Mike, > > > > > > > > I am growing to believe I need to deploy each plug-in as a > > > > > > > separate > > > > > > > WAR on a web-server. Is this true, or have I missed something? > > > > > > > In the case of my architecture, it is even a requirement that every > > > > > > plugin will be deployed as an own WAR file. It allows different > > > > > > teams > > > > > > working in parallel in completely independent applications (plugins) > > > > > > which have a common "message data model". When inside the plugins > > > > > > container, they receive messages with this "common data model". When > > > > > > out of the plugins container, the show a simplified UI to let the > > > > > > developer pass a "message" generated by hand and therefore test the > > > > > > application. > > > > > > > > I am also using gwt-exporter to make the JSNI messaging mechanism; > > > > > > > i.e. I just write an "Exportable" class and use the resulting JS > > > > > > > API > > > > > > > from my plugins. I am hoping to use gwt-api-interop to remove the > > > > > > > need > > > > > > > to use the JS API. > > > > > > > I have seen gwt-exporter but do not know gwt-api-interop. > > > > > > > > I assume the JS "bridge" between GWT applications handles the > > > > > > > messaging between them (i.e. plugins register callbacks to handle > > > > > > > messages sent from the "host"?) > > > > > > > Yes. > > > > > > > > If I understand correctly, adding additional script tags to my > > > > > > > "loader" page and having each plug-in as a separate WAR I avoid > > > > > > > the > > > > > > > need to inherit in my gwt.xml file? > > > > > > > My common model and plugin base classes live in a common GWT module > > > > > > that each plugin inherits. > > > > > > > > An example of your use of JavaScriptObject in your messaging sub- > > > > > > > system would be interesting.... > > > > > > > // Application specific common model > > > > > > public final class CustomerInfo extends ModuleInfo { > > > > > > protected CustomerInfo() { > > > > > > } > > > > > > > public native String getId() /*-{ > > > > > > return this.id; > > > > > > }-*/; > > > > > > > public native void setId(String id) /*-{ > > > > > > this.id = id; > > > > > > }-*/; > > > > > > > } > > > > > > > // Base class for common models - no functionality as of now > > > > > > public class ModuleInfo extends JavaScriptObject { > > > > > > protected ModuleInfo() { > > > > > > } > > > > > > > } > > > > > > > // To be implemented by every module > > > > > > public interface IModule<T extends ModuleInfo> { > > > > > > public String getName(); > > > > > > public void dispatch(String containerId, T moduleInfo); > > > > > > > } > > > > > > > // To be implemented by the main module or classes interested in > > > > > > module lifecycle events > > > > > > public interface IModuleAware<T extends ModuleInfo> { > > > > > > public void onModuleAttached(Module<T> module); > > > > > > > } > > > > > > > // Durable callback implementation - Because it uses JSNI, can be > > > > > > inherited from GWT modules but it is interoperable. Avoids using > > > > > > gwt- > > > > > > exporter > > > > > > public final class ModuleListener<T extends ModuleInfo> extends > > > > > > JavaScriptObject { > > > > > > protected ModuleListener() { > > > > > > } > > > > > > > public void onModuleAttached(Module<T> module) { > > > > > > invokeCallback(getCallback(), module); > > > > > > } > > > > > > > private native void invokeCallback(JavaScriptObject callback, > > > > > > Module<T> module) /*-{ > > > > > > this.callback(module); > > > > > > }-*/; > > > > > > > private native JavaScriptObject getCallback() /*-{ > > > > > > return this.callback; > > > > > > }-*/; > > > > > > > public native void setCallback(JavaScriptObject callback) /*-{ > > > > > > this.callback = callback; > > > > > > }-*/; > > > > > > > } > > > > > > > // Support for common > > ... > > read more » -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
