Friday, May 18, 2012

Timing issue when using JSNI in gwt.

Hi there,
I have a gwt project who uses JSNI methods to load values from
javascript into Java.
the myProject.html contains a script tag referring to javascript file
containing javascript files.
I call the JSNI methods directly from onModuleLoaded() method to
return the javascript values.
Running the application in development mode, works OK, but running it
after compile 'and deploying war file to the server side doesn't run
and indicates
some timing issues which I guess is about the the javascript/html not
yet loaded when the application uses JSNI methods.
The following are the code snippets:
- "myProject.html" in the 'war' folder contains the following script
tag to include the javascript file:

<script type="text/javascript" language="javascript" src="scripts/
browserSupport.js"></script>

- the java script file (in my case 'browserSupport.js') simply
contains the following variable:

brVersionMap={"IE":"8","Firefox":"15","Chrome":"17","Safari":"5"};

- From inside onModuleLoad() of "MyProject.java" I call the JSNI
methods defined in "myProject.java"

public class MyProject implements EntryPoint {

public void onModuleLoad() {
...

JavaScriptObject jsBrVerObj = (JavaScriptObject) getBrVersionMap();

//process jsBrVerobj ...

}


public static native Object getBrVersionMap() /*-{
return $wnd.brVersionMap ;
}-*/;
}

I need to invoke the JSNI method "getBrVersionMap()" after I know the
html/javascript has been fully loaded and ready.
Any help is appreciated.

--
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