2011-06-17 86 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