GWT JSNI Bridge Question

27 views
Skip to first unread message
Message has been deleted

drtman

unread,
Oct 2, 2011, 6:39:58 PM10/2/11
to Google Web Toolkit
I am not an expert in Javascript. However, I need to make a callback
into my GWT app from a <script> tag in an HTML page that is
dynamically loaded into an iframe (GWT Frame). In a nutshell, I have
the native function, and the export of that function working on the
client side, and I can see the variables defined in the DOM tab in
Firebug. However, I am not sure what the JS code inside the <script></
script> tag should look like. Can't I just do something like this:

<script language="javascript">$wnd.myFunc()</script>
or...
<script language="javascript">window.myFunc()</script>

??
Either one of those gives errors that "myFunc" is not defined
(ReferenceError). I am not sure if I am doing the call within the
<script></script> tag incorrectly, or if there is some problem with
the fact that this is happening inside of an iframe that is
dynamically loaded after the initial page (even though they originate
from the same domain)?

This is the export of the function that happens earlier in the app
(before the HTML with the script call is downloaded into an iframe),
and I am pretty sure this is all working correctly.

public static void myFunc()
{
// does some stuff
}

public static native void exportMyFunc()
/*-{
$wnd.myFunc = $entry(@myPackage.MyClass::myFunc());
}-*/;

Any ideas?

Thomas Broyer

unread,
Oct 2, 2011, 7:35:10 PM10/2/11
to google-we...@googlegroups.com
As it's in an iframe: parent.myFunc()
Reply all
Reply to author
Forward
0 new messages