Stephen,

You're most likely going to need to use the $wnd or $doc variable
within your JSNI code as the Garmin JS is not loaded into the same
area as GWT code (http://code.google.com/webtoolkit/doc/1.6/
DevGuideCodingBasics.html#DevGuideJavaScriptNativeInterface)

i.e. var display = new $wnd.Garmin.DeviceDisplay("garminDisplay",
{........

//Adam

On 21 Nov, 20:25, Stephen Walsh <stephenwalsh....@gmail.com> wrote:
> I am trying to use the above api to implement some JSNI code in my
> onModuleLoad method.  I am having the darnedest time trying to get it to
> recognize that I have the extra javascript files available.  The JS debugger
> in Chrome keeps saying that Garmin is undefined (see below).  Here's the
> dilemma: when I create my JSNI it gets compiled in the main JS code and
> evidently the Garmin JS code is out of the scope of where the call happens
> in the compiled JS.  I'm somewhat new to GWT, and I'm not sure if I'm doing
> something incorrectly or not. Here's what I've got in my project:
>
> src
> ---public
> ------communicator-api
> ---------miscellaneous garmin folders in the original structure
> ---garmin_project.gwt.xml
>
> com.stephenlwalsh.garmin_project.client
> ---garmin_project.java
>
> Contents of garmin_project.gwt.xml  The script src tags are doing a fine job
> of pulling in the js needed and the entire communicator-api folder on
> compile.
>
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 1.7.1//EN" 
> "http://google-web-toolkit.googlecode.com/svn/tags/1.7.1/distro-source...
> ">
> <module rename-to='garmin_favorites_sync'>
>   <!-- Inherit the core Web Toolkit stuff.                        -->
>   <inherits name='com.google.gwt.user.User'/>
>
>   <!-- Inherit the default GWT style sheet.  You can change       -->
>   <!-- the theme of your GWT application by uncommenting          -->
>   <!-- any one of the following lines.                            -->
>   <inherits name='com.google.gwt.user.theme.standard.Standard'/>
>   <!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> -->
>   <!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/>     -->
>
>   <!-- Other module inherits                                      -->
>   <script src="http://www.google.com/uds/api?file=uds.js&v=1.0&gwt=1
> "/>
>   <script src="communicator-api/garmin/device/GarminDeviceDisplay.js"/>
>   <script src="communicator-api/prototype/prototype.js"/>
>   <stylesheet src="communicator-api/garmin/device/style/communicator.css"/>
>   <!-- Specify the app entry point class.                         -->
>   <entry-point
> class='com.stephenlwalsh.garminsync.client.Garmin_Favorites_Sync'/>
> </module>
>
> JSNI function within EntryPoint()
>
>     private native void load() /*-{
>         var display = new Garmin.DeviceDisplay("garminDisplay", {
>             pathKeyPairsArray:
> ["http://developer.garmin.com","49048b3369edffd4a511d920202a6214";],
>
>             autoFindDevices: true, //start searching for devices
>             showStatusElement: true, //basic feedback provided
>             showReadDataElement: false //don't offer to read data
>             //add other options per the documentation
>             });
>     }-*/;
>
> From within onModuleLoad() I have the function called and it works fine.
> The problem lies within the line above in the var display declaration.  It
> says that "Garmin" is undefined.  I have moved files and reworded and
> everything trying to give that function access to the JS that it should have
> access to.  It's interesting that when I place the js load function in the
> html, it works just fine even when GWT is compiling the external javascript.
>
> Any thoughts?
>
> Thanks,
> Stephen Walsh

--

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


Reply via email to