communication between two frames

59 views
Skip to first unread message

Aditya

unread,
Oct 18, 2010, 3:26:09 AM10/18/10
to Google Web Toolkit
Hello Guys,

I am designing a web application using GWT which has one
inner frame which loads different modules whenever user selects any
menu from TOP frame that is from a main window.

The problem where i have stuck now is whenever there is some error
occurred inside a frame which contains a different module then that
should notify main window about it. So I can handle all failure
messages in my main module.

If anyone has implemented it before or has some threads that u have
gone thr' then please do reply.

I had referred this http://gwt-ext.com/forum/viewtopic.php?f=2&t=2459
this works fine as it is opening a new window but i want to open a
frame inside a same window which sends messages to parent window
containing it.

--
Aditya

ep

unread,
Oct 18, 2010, 4:33:33 AM10/18/10
to Google Web Toolkit
hi, a small question, do you open contents from same host (as parent
window) within your innerframe?

On 18 Okt., 09:26, Aditya <007aditya.b...@gmail.com> wrote:
> Hello Guys,
>
>               I am designing a web application using GWT which has one
> inner frame which loads different modules whenever user selects any
> menu from TOP frame that is from a main window.
>
> The problem where i have stuck now is whenever there is some error
> occurred inside a frame which contains a different module then that
> should notify main window about it. So I can handle all failure
> messages in my main module.
>
> If anyone has implemented it before or has some threads that u have
> gone thr' then please do reply.
>
> I had referred thishttp://gwt-ext.com/forum/viewtopic.php?f=2&t=2459

aditya sanas

unread,
Oct 18, 2010, 5:20:20 AM10/18/10
to google-we...@googlegroups.com
yes those are from same host in the same window.

I have somewhere about 10 modules in my project out of which 1 is main modules which contains a Frame(GWT).
and in this frame i m loading other 9 modules in the same window.
So i want main window and frame should communicate with each other.
that is there is should be some kind of message passing between these two modules but i m finding it little difficult to do it as both are from different modules and so the objects in one module is not accessible to the other.

--
Aditya


--
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.


ep

unread,
Oct 18, 2010, 5:56:14 AM10/18/10
to Google Web Toolkit
actually, you could be using HandlerManager as an event bus between
all your modules, but I guess you trying to treat each of your modules
as separate "gwt applications", each having an entry point and also
each independently compilable / runnable? therefore you cannot just
reference classes cross-wise?

in this case you could create a small API allowing message interchange
or you follow observer pattern and the host page (being a master) can
provide the implementation as a native JS code.


On 18 Okt., 11:20, aditya sanas <007aditya.b...@gmail.com> wrote:
> yes those are from same host in the same window.
>
> I have somewhere about 10 modules in my project out of which 1 is main
> modules which contains a Frame(GWT).
> and in this frame i m loading other 9 modules in the same window.
> So i want main window and frame should communicate with each other.
> that is there is should be some kind of message passing between these two
> modules but i m finding it little difficult to do it as both are
> from different modules and so the objects in one module is not accessible to
> the other.
>
> --
> Aditya
>
> > google-web-tool...@googlegroups.com<google-web-toolkit%2Bunsu...@googlegroups.com>
> > .

aditya sanas

unread,
Oct 18, 2010, 6:25:45 AM10/18/10
to google-we...@googlegroups.com
yeah you are right my each of the module is compilable each is having entryPoint class associated with it but 
this is how we use to design a GWT module or is it possible to have GWT module without EntryPoint class associated with it...?

actually we were having a single enrty point class for this module before but it was making page very heavy.And it was taking more than 10seconds each time to load when we deploy project online.
So for this we had decided to split modules and each page will have different module associate with it.

but still we are not able find a solution for communication between two modules.
and i didn't get your last line.

I m trying this as 
following method is from master class as 

CandidateMainView.java implements EntryPoint
//...
public static native void alertWindow()/*-{
$wnd.alert('hello there i m in main...');
}-*/;


and i m trying to access this method from some other class which is getting loaded into the inner frame.
CandidateAccountSetting.java implements EntryPoint

//..
private native void registerAFunction() /*-{
@com.verisona.bridge.client.CandidateMainView::alertWindow();

}-*/;

this should give an alert but it doesn't work.
is this what u r suggesting ?

--
Aditya


To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.

ep

unread,
Oct 18, 2010, 7:58:24 AM10/18/10
to Google Web Toolkit
ah ok got your point, well, if you write:

@com.verisona.bridge.client.CandidateMainView::alertWindow();

for the GWT compiler is pretty same as a pure Java call - because that
code is not actually "native" where as

$wnd.alert("foo")

is a real native code which is not handled by GWT compiler. the first
line would not work cross anonymous modules (such as those which are
not compiled within same compilation process) since the obfuscator
will rename all the types/method names. when I've written "native" i
really meant pure Java-Code which is not compiled by GWT compiler, but
rather is supplied from a separate codeBase.js (javascript) file.
because that code you always can use cross-modules like
$wnd.myBus.fire("myModule","initState").

The issue is that you have to compile all available modules in same
compile process to get them working with each other via compile time
binding (such as calling ModuleA.refresh() from ModuleB), after
compilation (with obfuscation) there is no way to reach the code via
API.

Have you already tried code splitting feature to minimize the initial
bootstrap? so that codebase from "moduleX" is loaded on demand?
> > <google-web-toolkit%2Bunsu...@googlegroups.com<google-web-toolkit%252Buns...@googlegroups.com>

aditya sanas

unread,
Oct 19, 2010, 12:45:57 PM10/19/10
to google-we...@googlegroups.com
 thanks for ur reply and kind help.
i am still searching for the right solution.
I have implemented what u have specified in the la st thread as -  $wnd.myBus.fire("myModule","initState") 
 this works fine  when i m opening both  the modules in different (seperate) windows of the same browser. but whenever i try this using inner frame it doesn't work as it should be.

so for guiding purpose if you can  share a code snippet that might help me for better understand.

And yes,we had thought of  code splitting but we couldn't implemented it.

thanks.
--
Aditya


To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.

ep

unread,
Oct 20, 2010, 3:43:35 AM10/20/10
to Google Web Toolkit
oh yes, I forgot to mention that innerframes behave like window and
have own javascript namespace so if you're using the default GWT
linker, which loads the application in innerframes and your hosted
page provides your sharedCodeBase.js file, then you should interop via
the top window which initially loaded the hosted page, you can reach
the top window via $wnd.top ( to get the parent of the innerframe you
can also do $wnd.parent )

//register moduleA as listener
$wnd.top.myBus.addListener("SOME_GLOBAL_EVENT", this)

//register moduleB as listener
$wnd.top.myBus.addListener("USER_LOGIN_EVENT", this)

//fire a LOGIN EVENT from moduleA and moduleB will get notified
$wnd.top.myBus.fire("USER_LOGIN_EVENT", this)


btw:
you have to operate on events described by STRINGs, so they sustain
the obfuscation, therefore you cannot use the HandlerManager class
from GWT as a bus, but rather write your own one, follow the Observer
pattern...watchout further you have to interop via JSON messages
rather than Java classes, remember any API is dead after obfuscation.

but I would really advise you to give a try the code splitting feature
also to minimize the code footprint, and I dont think that GWT is
optimized for this "binary" deployment model where you can compile
multiple stand-alone runnable modules and than just make them working
together without a new recompilation! of course there're workaround
like above, one can also implement message queue etc but I think you
better should raise a feature request to development team and maybe
they have (or gonna provide) a better solution, which also is
optimized for performance



On 19 Okt., 18:45, aditya sanas <007aditya.b...@gmail.com> wrote:
>  thanks for ur reply and kind help.
> i am still searching for the right solution.
> I have implemented what u have specified in the la st thread as -
>  $wnd.myBus.fire("myModule","initState")
>  this works fine  when i m opening both  the modules in different (seperate)
> windows of the same browser. but whenever i try this using inner frame it
> doesn't work as it should be.
>
> so for guiding purpose if you can  share a code snippet that might help me
> for better understand.
>
> And yes,we had thought of  code splitting but we couldn't implemented it.
>
> thanks.
> --
> Aditya
>
> > > > <google-web-toolkit%2Bunsu...@googlegroups.com<google-web-toolkit%252Buns...@googlegroups.com>
> > <google-web-toolkit%252Buns...@googlegroups.com<google-web-toolkit%25252Bun...@googlegroups.com>

pratik

unread,
Nov 3, 2010, 6:03:49 AM11/3/10
to Google Web Toolkit
Hi Aditya,
Can you please share your implementation of communicating between
iframe and main window ?
Reply all
Reply to author
Forward
0 new messages