Frage

Ich fand im Internet eine Anwendung mit GWT und ich schreibe, dass es eine Bibliothek ist leicht gdata Funktionen nicht zu nutzen. Insbesondere muss ich die Integration mit Google Kalender verwenden. Ich folgte den offiziellen Führer auf gwt-gdata Website um die Authentifizierung zu tun ( http: / /code.google.com/p/gwt-gdata/wiki/GettingStarted ), aber leider habe ich einen Fehler. Dies ist der Fehler:

  17:59:12.463 [ERROR] [testmappa] Unable to load module entry point class testMappa.client.TestMappa (see associated exception for details)
    com.google.gwt.core.client.JavaScriptException: 
(TypeError): $wnd.google.accounts is undefined
     fileName: http://127.0.0.1:8888
     lineNumber: 29
     stack: ("http://www.google.com/calendar/feeds/")@http://127.0.0.1:8888:29
    connect("http://127.0.0.1:8888/TestMappa.html?gwt.codesvr=127.0.0.1:9997","`gL1<a3s4B&Y{(Ci","127.0.0.1:9997","testmappa","2.0")@:0
    ((void 0),"testmappa","http://127.0.0.1:8888/testmappa/")@http://127.0.0.1:8888/testmappa/hosted.html?testmappa:264
    z()@http://127.0.0.1:8888/testmappa/testmappa.nocache.js:2
    (-2)@http://127.0.0.1:8888/testmappa/testmappa.nocache.js:8
        at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:195)
        at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:120)
        at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:507)
        at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:264)
        at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
        at com.google.gwt.accounts.client.User.login(User.java)
        at testMappa.client.TestMappa.onModuleLoad(TestMappa.java:68)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at com.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:369)
        at com.google.gwt.dev.shell.OophmSessionHandler.loadModule(OophmSessionHandler.java:185)
        at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:380)
        at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:222)
        at java.lang.Thread.run(Thread.java:637)

Ich bin nicht in der Lage, den Grund dieses Fehlers zu verstehen. Mein Code ist einfach:

    String scope = "http://www.google.com/calendar/feeds/";

    User.login(scope);

Und soweit ich weiß, es sollte funktionieren, wie es ist. Ich weiß nicht, was zu tun ist und ich bin hier zu fragen, wie dieses Problem zu lösen, und wenn ich direkt gdata nativen Java-Bibliothek verwenden kann, aber ich glaube, das anderes, was nicht möglich ist, für die clientseitige GWT-Code zu tun ( da der Code in Javascript umgewandelt wird).

Danke.

War es hilfreich?

Lösung

Die beiden Codezeilen Sie oben tatsächlich eingefügt sollen wie diese innerhalb der run-Methode kommen -

if (GData.isLoaded(GDataSystemPackage.CALENDAR)) {
   Window.alert("Package is loaded");
} else {
   GData.loadGDataApi("MyApiKey",
      new Runnable() {
        public void run() {
             String scope = "http://www.google.com/calendar/feeds/";
             User.login(scope);
             //remaining code comes in here. you may create a new method
             //and call it from here.
        }
      },
      GDataSystemPackage.CALENDAR);
}

Wenn Sie nicht über den GData-API-Code laden, sind Sie wahrscheinlich die Javascript-Fehler erhalten, die Sie eingefügt.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top