Hi Saeed, David, and all others,
I developed an AppLink class that can be used for the communication
between the main and sub apps. The main app creates an AppLink
instance and sets it on an iframe element. The sub application that is
loaded in the iframe gets the AppLink instance from the iframe. Both,
the main app and the sub app can set a listener that is called when an
event is triggered by the other app.
Comments on my class are welcome!
--Stefan
public class AppLink extends JavaScriptObject {
public static native AppLink create() /*-{
return new Object;
}-*/;
public static native AppLink getAppLinkFromFrame() /*-{
if ($wnd.frameElement && $wnd.frameElement.appLink) {
return $wnd.frameElement.appLink;
}
return null;
}-*/;
protected AppLink() {}
public final native void setAppLinkOnElement(Element anElement) /*-{
anElement.appLink = this;
}-*/;
public final native void setMainAppListener(IAppLinkListener
aListener) /*-{
if (aListener == null) {
this.mainAppListener = null;
} else {
this.mainAppListener = function(event) {
[email protected]::onAppEvent
(Ljava/lang/String;)(event)
}
}
}-*/;
public final native void setSubAppListener(IAppLinkListener
aListener) /*-{
if (aListener == null) {
this.subAppListener = null;
} else {
this.subAppListener = function(event) {
[email protected]::onAppEvent
(Ljava/lang/String;)(event)
}
}
}-*/;
public final native void signalMainAppEvent(String anEvent) /*-{
if (this.mainAppListener) this.mainAppListener(anEvent);
}-*/;
public final native void signalSubAppEvent(String anEvent) /*-{
if (this.subAppListener) this.subAppListener(anEvent);
}-*/;
}
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---