GwtFB难度大

时间:2011-06-17 06:33:43

标签: javascript facebook gwt

我成功检出了GwtFB并在GWT 2.3中运行了该项目。但是,我尝试将其复制到我自己的项目中,并且失败并出现以下错误:

com.google.gwt.core.client.JavaScriptException: (TypeError): Cannot call method 'appendChild' of undefined
    at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:237)
    at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:132)
    at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561)
    at com.google.gwt.dev.shell.ModuleSpace.invokeNativeVoid(ModuleSpace.java:289)
    at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeVoid(JavaScriptHost.java:107)
    at com.foo.client.sdk.FBCore.init(FBCore.java)
    at com.foo.client.bar.onModuleLoad(bar.java:39)
    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:396)
    at com.google.gwt.dev.shell.OophmSessionHandler.loadModule(OophmSessionHandler.java:193)
    at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:510)
    at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:352)
    at java.lang.Thread.run(Thread.java:662)

我的代码中失败的行:

private static final String ApiKey = "myKey";

private FBCore fbCore = GWT.create(FBCore.class);
private FBEvent fbEvent = GWT.create(FBEvent.class);

private boolean status = true;
private boolean xfbml = true;
private boolean cookie = true;

private MainView mainView;

/**
 * This is the entry point method.
 */
public void onModuleLoad() {
    fbCore.init(ApiKey, status, cookie, xfbml); // fails
            ...

我试图将示例项目中的每个细节都复制到我自己的项目中。我做错了什么?

1 个答案:

答案 0 :(得分:3)

您是否忘记在html文件中包含以下内容?

<div id='fb-root'></div> 
    <script src='http://connect.facebook.net/en_US/all.js'></script>