using exported functions between multiple gwt modules on same html launch page

41 views
Skip to first unread message

shawn

unread,
Jan 5, 2012, 3:25:21 PM1/5/12
to gwtexporter
Hello, I'm working on refactoring a currently monolithic gwt 2.0
application into separate gwt modules each with it's own entrypoint(at
least I think I need to have it that way). At runtime i would
dynamically determine which modules get loaded and place <javascript>
tags on the html launch page referring to the nocache.js for each
module. This much seems pretty straightforward, but I had two
questions about what's possible for intercommunication between the
modules using gwtexporter:

1. For example, I need modules to invoke methods on each other, like
moduleA needs to call moduleB.method1(). In that case do I need to
drop down to JSNI from moduleA to invoke the exported 'method1' from
moduleB or is their a more elegant gwt wrapper solution I could use
around that?

2. It appears like it's not possible to pass GWT UI widgets across
exported functions? i.e. I can't export a function with a signature
such as:

moduleB.method2(com.google.gwt.user.client.Window window,
com.google.gwt.user.client.ui.Widget widget);

or is there some way to accomplish this using
com.google.gwt.core.client.JavaScriptObject?

any info/pointers much appreciated, thanks!

Manuel Carrasco Moñino

unread,
Jan 9, 2012, 3:29:55 PM1/9/12
to gwtex...@googlegroups.com
If you get a gwt object from a jsni method, you could pass it to another jsni method, but you can not manipulate it in js unless you know the gwt internals of this object.

This should work, if not  there is a bug in gwt-exporter

var o = mynamespace.getMyGwtInstance();
mynamespace.myMethod(o);


public MyObject getMyGwtInstance() {
   return new MyObject(....);
}

public void myMedhod(MyObject gwtObject) {
Reply all
Reply to author
Forward
0 new messages