Hi,

In an  application that uses Highchats and Bootstrap, the 
"com.google.gwt.core.client.ScriptInjector" does not seem to be working 
correctly for me. 

Basically, during the onLoad() of my entrypoint, if I try to inject js 
Highcharts.js dependency using the core gwt injector, I end up not 
seing absolutely nothing injected into the Head of the html. 
Though i can see that the Inject Method is tring to put the javascript 
string into the Head... it just does not seem to be there when the module 
loads.

This does not work:

public static void injectHighchartsJavascriptIntoHtmlHead(){
TextResource textResource = HIGHCHARTS_JS_RESOURCE.highchartsJs();
if(!highchartsJsResourceInjected){ 
com.google.gwt.core.client.ScriptInjector.fromString(textResource.getText()).inject();
highchartsJsResourceInjected = true;
} 
}

when the From String completes, automatically the following javascript 
error takes place in the browser:
" 

   1. Uncaught TypeError: undefined is not a function 
hosted.html:30<http://127.0.0.1:8888/gwtexpenses/hosted.html?gwtexpenses>
      1. (anonymous 
function)hosted.html:30<http://127.0.0.1:8888/gwtexpenses/hosted.html?gwtexpenses>
      2. (anonymous 
function)hosted.html:246<http://127.0.0.1:8888/gwtexpenses/hosted.html?gwtexpenses>
      3. 
      
@com.google.gwt.core.client.ScriptInjector::nativeAttachToHead(Lcom/google/gwt/core/client/JavaScriptObject;Lcom/google/gwt/core/client/JavaScriptObject;)
      4. 
__gwt_jsInvokehosted.html:76<http://127.0.0.1:8888/gwtexpenses/hosted.html?gwtexpenses>
      5. gwtOnLoad
      
      
"



On the other hand, if I modify my onLoad to instead of calling the Resource 
inject function, I use the non core Bootstrap resource injector:

String javascriptToInject = 
org.moxieapps.gwt.highcharts.client.resources.Resources.getHighchartsJs().getText();
com.github.gwtbootstrap.client.ui.resources.JavaScriptInjector.inject(javascriptToInject);


Well, then I have no problems.
One thing is clear, both mechanisms of populating the head element are 
nothing alike. The core core seems optimized to use native functions,
The bootstrap Script Injector, on the other hand, gets the Header Drom and 
populates using gwt Dom wrappers. In this case, you actually see the point 
in time where your javascript gets injected and that required dependencies, 
e.g. jQuery have also been dumped into the header.

Thanks in advance for any input!

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-web-toolkit+unsubscr...@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to