Hi,
I'm working on a front with a global portal as a placeholder for
applications. Each application is an independent GWT module opened in
an iframe. The portal and all applications can talk one to each other.
Each application can send messages to the portal about it state
(working, title...). But the main feature is to have only one
connection to the server shared by all applications. The portal has a
data manager which manage data exchange with the server
(authentication, caching...). All application ask data to the portal.
When a data object is changed, the portal broadcasts the new object to
all applications... and so on.
So, to answer to your question, I use a messaging system. It's based
on the postMessage method (and it's "window.name" compatibility
implementation). I'm using a bootstrap process that allows a new
application to discover all other applications and register itself to
them. Then, I exchange JSON object (serialized as a String). It's for
me the best way because I never used GWT-RPC. Instead, we have a REST
server offering data as JSON object. A tool use server classes to
produce GWT classes which works have proxy to JavaScriptObject. For
better understand, a little piece of code:
- A special JavaScriptObject (not data-specific) to mange JSON with
ease
public class JsObject extends JavaScriptObject {
...
public native final String getString(String name)
/*-{
return this[name];
}-*/;
...
}
- A data-class (generated) which wraps a JSON object
public class MyData {
private JsObject jso;
...
public String getName()
{
return jso.getString("name");
}
...
}
- The unserialization process
String data = <data from server/messaging system> ;
JavaScriptObject jso = eval(data);
MyData result = new MyData((JsObject)jso.cast());
To send object through the messaging system, we just serialize the
JavaScriptObject as a String. On the other end, we just eval the
String and create instantiate a GWT-class to wrap the JSON object. The
benefits are: zero overhead for serialization/unserialization and same
process for data coming from/going to the server, the messaging
system, a storage system (cookie, HTML 5...)...
I hope this help.
Olivier
On 19 mar, 15:54, Jonathan Hunt <[email protected]> wrote:
> Hi
>
> Thanks for your help. I guess my question wasn't so much how to do but
> more advice on a good, clean way of implementing it in gwt. Basically
> I want interframe rpc. Something like the server rpc in gwt where you
> don't have to manually deal with serialization etc. I was hoping
> someone might have done something similar and might have a few pointer
> on the best way of architecturing it cleanly since I'm fairly new to
> gwt.
>
> Thanks for any help
> J
>
>
>
> On Friday, March 19, 2010, Pondmouse <[email protected]> wrote:
> > I did something similar by writing native javascript. See here
> >http://googlewebtoolkit.blogspot.com/2008/07/getting-to-really-know-g...
>
> > I had trouble getting the embedded iframes call the javascript
> > functions. See herehttp://www.dyn-web.com/tutorials/iframes/
>
> > Managed to call the javascript functions using top.functionname()
>
> > On Mar 19, 6:23 am, Sudeep S <[email protected]> wrote:
> >> hey Jonny,
>
> >> jquery has a plugin for window.post that works for all browsers.
> >> i've used that with gwt for resizing cross domain iframe.
> >> you can give that a shot.
>
> >> On Thu, Mar 18, 2010 at 2:08 PM, jjh <[email protected]> wrote:
> >> > Hi,
>
> >> > I am wanting allow extensions to my website (essentially third-party
> >> > javascript code that can provide response to certain events, sort of
> >> > simplified, gui-less gadgets). It seems like the safest way to this is
> >> > to use iframes and inter-frame communication to limit what the third-
> >> > party code can do (to some extent).
>
> >> > So now I need to be able to post events to the gadget-frames and
> >> > receive responses (basically RPC between frames). I know this can be
> >> > done in javascript using postMessage (window.name hacks for older
> >> > browsers). But I'm not sure what the best way to do this in GWT is.
> >> > Does anyone have any pointers for a clean way of doing this in GWT.
>
> >> > Regards,
> >> > Jonny
>
> >> > --
> >> > 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]<google-web-toolkit%[email protected]>
> >> > .
> >> > For more options, visit this group at
> >> >http://groups.google.com/group/google-web-toolkit?hl=en.
>
> > --
> > 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
> > athttp://groups.google.com/group/google-web-toolkit?hl=en.
>
> --
> Jonathan J Hunt <[email protected]>
> Homepage:http://www.42quarks.com
> (Further contact details there)
> "Physics isn't the most important thing. Love is." Richard Feynman
--
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.