Dynamic Module Loading

1,805 views
Skip to first unread message

lineman78

unread,
Mar 30, 2010, 9:10:32 PM3/30/10
to Google Web Toolkit
I know this is a common request of people trying to make pluggable
applications. It seems that every time someone comes up with a
solution to this problem the GWT team changes the way the core linkers
work and break the solution. I was wondering if anyone knows a way to
dynamically load a module either with a new linker, or a different
method than the traditional appending a new script element to the end
of the body. I try to append a script element to the end of the body
and it completely blows the document away and freezes the page in a
loading mode. I found an email exchange between members of the GWT
contributors group in December where they discuss new methods for the
default linkers using dynamic iframes. I have been exploring this
capability since 1.5 and every time I revisit it the method(hack job)
I used the last time will not work. I would really like a more
consistent method.

Every forum I have seen where someone asks this someone inevitably
asks why, so let me head off this question by explaining. I have run
into this in a few different situations, one when trying to integrate
GWT "portlets" into Liferay(Java portlet). The second situation is in
trying to create a dynamic binding of sorts. I have been trying to
figure out a way to create a GWT portal where you could install
modules and they could be added and removed dynamically without having
to recompile the core, creating something similar to iGoogle or
Liferay in a GWT/J2EE implementation.

Olivier Monaco

unread,
Mar 31, 2010, 4:14:56 AM3/31/10
to Google Web Toolkit
Hi,

I don't know if I'll answer your question but we working on a main GWT-
module with pluggable sub-modules. Each sub-modules is an ui-
independant part of the whole application. To avoid interferences,
each module loads into its own iframe. I wrote a messaging system that
allow each module to communicate with each other (JSON serialization,
auto-discovery of other modules...).

Olivier

lineman78

unread,
Mar 31, 2010, 12:18:15 PM3/31/10
to Google Web Toolkit
Yeah, there is 1 problem I have with your solution and a separate
issue your solution doesn't address. The problem I have with your
solution is that iFrames can't inherit size. One behavior I like is
that you can stack the modules and they will fit tightly against the
other and the one below will move if the upper one's height changes,
i.e. a disclosure panel. The issue that your issue doesn't seem to
resolve is that I would like to dynamically add the modules to the
page as they are added and would like the main module to not know
anything about them other than the fact that they extend an abstract
sub module and the location of the module's nocache.js.

Sripathi Krishnan

unread,
Mar 31, 2010, 2:12:27 PM3/31/10
to google-we...@googlegroups.com
GWT's architecture is orthogonal to your requirement of dynamic module loading / pluggable sub-modules, so whatever solution you find will be a hack and not maintainable.

One of the core philosophies of GWT - If something can be done at compile time, do it. The key benefit of such a philosophy is performance. GWT scores over a lot of other frameworks because of its monolithic, closed-world compile. Any framework for dynamic module loading needs to defer a few operations to runtime, and that is a cost GWT core is unwilling to pay (thats what I understand).

Having said that, you can still achieve what you want. Define an API (in terms of javascript methods) for your module, and use GWT Exporter to export the methods. That way, your GWT modules can inter-operate with hand-written javascript or with other pre-compiled GWT code. You can also dynamically add new modules to a page if you wish to do so. Any shared/common will however get download multiple times as part of each modules nocache.js + guid.cache.html, and there is nothing you can do about it.


--Sri



--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.


lineman78

unread,
Mar 31, 2010, 6:10:26 PM3/31/10
to Google Web Toolkit
I agree with everything you have said and this is the approach I am
experimenting with except for one problem. Since 2.0 it is not
possible to load modules dynamically. I have written a jsp that will
add all the installed plug-ins' scripts to the head when the page is
loaded, but unfortunately this causes a lot of unnecessary start-up
loading. I am going to look into putting the entire instantiation
under a runAsync and that should hopefully fix the problem. It would
still be nice to load the modules dynamically, but i guess it isn't a
huge deal to make them reload after installing a plug-in.

On Mar 31, 12:12 pm, Sripathi Krishnan <sripathikrish...@gmail.com>
wrote:


> GWT's architecture is orthogonal to your requirement of dynamic module
> loading / pluggable sub-modules, so whatever solution you find will be a
> hack and not maintainable.
>

> One of the core philosophies of GWT - *If something can be done at compile
> time, do it*. The key benefit of such a philosophy is performance. GWT


> scores over a lot of other frameworks because of its monolithic,
> closed-world compile. Any framework for dynamic module loading needs to
> defer a few operations to runtime, and that is a cost GWT core is unwilling
> to pay (thats what I understand).
>
> Having said that, you can still achieve what you want. Define an API (in
> terms of javascript methods) for your module, and use GWT

> Exporter<http://code.google.com/p/gwt-exporter/>to export the methods.


> That way, your GWT modules can inter-operate with
> hand-written javascript or with other pre-compiled GWT code. You can also
> dynamically add new modules to a page if you wish to do so. Any
> shared/common will however get download multiple times as part of each
> modules nocache.js + guid.cache.html, and there is nothing you can do about
> it.
>
> --Sri
>

> > google-web-tool...@googlegroups.com<google-web-toolkit%2Bunsu...@googlegroups.com>

Reply all
Reply to author
Forward
0 new messages