Saturday, May 19, 2012

Re: Timing issue when using JSNI in gwt.

Ok, so I was ruminating over this one. I just modified the default web project to the code you supplied and it worked fine. Not sure what is different between my code and yours.

The JSO class
package com.testbrowser.client;

import com.google.gwt.core.client.JavaScriptObject;

public class BrowserVersionList extends JavaScriptObject {
       
protected BrowserVersionList() {
       
}

       
public static BrowserVersionList newInstance() {
               
return createJso();
       
}

       
private static native BrowserVersionList createJso() /*-{
                return $wnd.brVersionMap;
        }-*/
;

       
public final native String getChromeVersion() /*-{
                return this.Chrome;
        }-*/
;
}

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

The main onModuleLoad body to show the version found:
public class BrowserSupportVersion implements EntryPoint {

        /**
         * This is the entry point method.
         */

       
public void onModuleLoad() {

               
BrowserVersionList browserVersions = BrowserVersionList.newInstance();
                GWT
.log("Chrome version supported: "+browserVersions.getChromeVersion());


               
// Create the popup dialog box
               
final DialogBox dialogBox = new DialogBox();
                dialogBox
.setText("Detecting supported browser versions");
                dialogBox
.setAnimationEnabled(true);

               
// We can set the id of a widget by accessing its Element
               
final Label textToServerLabel = new Label();
               
VerticalPanel dialogVPanel = new VerticalPanel();
                dialogVPanel
.addStyleName("dialogVPanel");
                dialogVPanel
.add(new HTML("<b>Supported Chrome version: <i>"+browserVersions.getChromeVersion()+"</i></b>"));
                dialogVPanel
.add(textToServerLabel);
                dialogVPanel
.setHorizontalAlignment(VerticalPanel.ALIGN_RIGHT);
                dialogBox
.setWidget(dialogVPanel);

               
RootPanel.get("notificationContainer").add(dialogBox);
       
}
}
I put this up and a version of my AppSpot account and it works from IE8, FF12, and Chrome 18.
http://4.runpartner.appspot.com/

Let me know if it works for you. Not sure what's causing your error. ( I cleaned the code up a little, but it ran as you had it too.)

Sincerely,
Joseph

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/kg1d0Lv3maoJ.
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