Sunday, October 2, 2011

GWT JSNI Bridge Question

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?

--
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-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate