I'm not 100% clear which way are you trying to go - are you trying to
call your GWT from the HTML page, or the other way around?

If the first, i.e. trying to call into your GWT app externally, then
you're more than likely running into a timing issue.  Your GWT code to
create the InjectJS bridge method will not be executed until the whole
page has been loaded by the Browser (when the onModuleLoad() method is
called) - but, that is probably after the point where the browser has
already tried to call the bridge method and you therefore get the "not
defined" error.

What you need to do is sync up - the only way I can think of, is to
have your GWT code call some JavaScript in your HTML page, which then
calls the code which will call back into your GWT app.... i.e. in your
app, have something like the following in addition to your bridge code


private native runWhenLoaded()/*-{
   $wnd.loaded();
}-*/;

public void onModuleLoaded(){
   injectJSBridge();
   runWhenLoaded();
}

then in your HTML page have someting like the following:

<script type="text/javascript" src='au.com.ndm.asa.Aasci.nocache.js'></
script>
<script type="text/javascript">
    function loaded(){
       injectJs("url referencing an external javascript");
    }
</script>

Now, the browser will load your GWT application, that will then set up
the bridge method, then call the loaded() method defined in the HTML
page, that in turn calls your bridge method.....

//Adam

On 21 Aug, 08:30, Kartik Rao <[EMAIL PROTECTED]> wrote:
> Cant seem to get this to work and its driving me nuts, any help would
> be much appreciated..
>
> Here's what I did..
>
> 1.) Created a standard eclipse project using the project creator and
> application creator scripts.
> 2.) The EntryPoint class is au.com.ndm.asa.client.Aasci
> 3.) Defined a native method called "injectJs"
>
> native static void injectJs( String url ) /*-{
>     var script = $doc.createElement("script");
>     script.src = url;
>     $doc.body.appendChild(script);
>     }-*/;
>
> 4.) Defined a bridge method called injectJsBridge
>
>     public native void injectJsBridge( ) /*-{
>         $wnd.injectJs = function( s ){
>         return @au.com.ndm.asa.client.Aasci::injectJs(Ljava/lang/
> String;)(s);
>         };
>     }-*/;
>
> 5.) The bridge method is called in the onModuleLoad
>
>     public void onModuleLoad()
>     {
>         injectJsBridge();
>     }
>
> 6.) Here is part of my application.html
>
>                 <script type="text/javascript"
> src='au.com.ndm.asa.Aasci.nocache.js'></script>
>                 <script type="text/javascript">
>                         injectJs("url referencing an external javascript");
>                 </script>
>
> When I attempt to call the the injectJs method which has been bridged
> from my application's html file, I get a javascript error that says
> "injectJs is not defined".
>
> What am I doing wrong ?
--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to