tags:

views:

26

answers:

1

I have a function Load() in a js file which I added to the GWT module.

I am trying to call it using

private static native void load() /*-{
   $doc.Load();
}-*/;

but it gives me error like

Error(s) occurred! (TypeError): $doc.Load is not a function fileName: http://localhost:8888/myapp/888C05FB242806B071A932498F6B5AD9.cache.html lineNumber: 1224

I even tried with $wnd.Load()

What the proper way of calling it?

A: 

Igor is correct. Consider the following snippet from the host HTML file:

<html>
  <head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <link rel="stylesheet" type="text/css" href="resources/css/gxt-all.css" />
    <script language="JavaScript">
    function dostuff() {
        alert("Stuff is being done.");
    }
    </script>

    <!--                                                               -->
    <!-- Consider inlining CSS to reduce the number of requested files -->
    <!--                                                               -->
    <link type="text/css" rel="stylesheet" href="GxtSandbox.css">

And the following snippet from GWT code:

public void onModuleLoad() {
    doGwtStuff();
}

public native void doGwtStuff() /*-{
    $wnd.dostuff();
}-*/;

This alert is shown.

BinaryMuse