First of GWT is just awesome.. but I ran into a little issue when
using 2 modules one page. I opened up an issue report here:
http://code.google.com/p/google-web-toolkit/issues/detail?id=1804
And I'm hoping to see if anyone else has run into this. I have a main
gwt module that upon a user clicking a button it creates a div with an
ID that a second module looks for and puts it's content into it. The
second module just adds a few buttons and stuff inside that div and
all seems well so far. Problem is that any mouse events over the
buttons in the 2nd module will produce JavaScript errors.
I've attached simple project to the issue that shows this error in
action. Anybody run into this? Any clues what might be causing this
issue?
Thanks,
Hiram
On Oct 25, 4:50 am, "hi...@hiramchirino.com" <chir...@gmail.com>
wrote:
The issue is that the event system seems to get confused when you
have more than one module on a page.
The simple solution for you would be to create a third module with
only a gwt.xml file.
something like
com.foo.bar.CombinedModules.gwt.xml
<module>
<inherits name="com.foo.bar.Module1"/>
<inherits name="com.foo.bar.Module2"/>
</module>
Then just compile that third module
and only have a single <script> tag for CombinedModules on your host
page.
What this does is combine the two modules into a single monolithic
module. they still will act separately, and each module's onModuleLoad
() will be called, but, you will gain a few benefits ...
1) reduced byte count at page load
you'll only need one copy of code common to both modules. For
instance if module1 and module2 both use Button then you'd have two
separate button implementations (one in each module) however with the
monolithic module there will only be one.
2) reduced request count at page load
Each module is initially going to generate 3 requests (maybe only 2
on some browsers) so by combining the modules in this way, you reduce
the request count (and thus speed up page startup)
3) events will work as expected
Event handlers are registered as a method on the global window
object, so the last module to load will handle all of the events, and
if that last module doesn't actually generate events of its own, it
is likely that you'll get a call to null.nullMethod() which is
definitely a javascript error. By combining the modules, both modules
are running off of the single global event handler.
hope this helps
-jason
Regards,
Hiram
On Oct 25, 4:24 pm, Peter Blazejewicz <peter.blazejew...@gmail.com>
wrote:
They attach the event handlers to the DOMImpl rather than to the
Window object, effectively creating separate event systems for each
module
give it a try and let me know if they work for you
-jason