2011-06-17 65 views
0

我成功检出了GwtFB并在GWT 2.3中运行了该项目。不过,我尝试将它复制到我自己的项目,它失败,出现以下错误:GwtFB难度很大

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

我试图拷贝每从示例项目到我自己的详细信息。我究竟做错了什么?

回答

3

您忘了在html文件中包含以下内容吗?

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

增加'

'修复它。 – 2011-10-17 22:17:08