2016-03-24 33 views
2

我對GWT相當陌生。我想擴展一些標準的小部件來滿足我的需求。我創建了我的第一個部件HorizontalTabs,從GWT質感設計(Here is demohere are sources)擴展類和我正在一個錯誤:Cannot read property 'hash' of undefinedGWT-自定義小部件錯誤:無法讀取未定義的屬性'哈希'

這裏是視圖代碼:

public class HorizontalTabs extends Composite { 

    private static HorizontalTabsUiBinder uiBinder = GWT.create(HorizontalTabsUiBinder.class); 

    interface HorizontalTabsUiBinder extends UiBinder<Widget, HorizontalTabs> { 
    } 
public HorizontalTabs() { 
    initWidget(uiBinder.createAndBindUi(this)); 
    } 
} 

<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent"> 
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder" 
    xmlns:g="urn:import:com.google.gwt.user.client.ui" xmlns:m="urn:import:gwt.material.design.client.ui"> 
    <m:MaterialRow> 
     <m:MaterialRow> 
      <m:MaterialColumn grid="s12"> 
       <m:MaterialTab ui:field="tab" backgroundColor="blue" indicatorColor="yellow" waves="YELLOW"> 

       </m:MaterialTab> 
      </m:MaterialColumn> 
     </m:MaterialRow> 
     <m:MaterialRow ui:field="tabContentRow"> 

     </m:MaterialRow> 
    </m:MaterialRow> 
</ui:UiBinder> 

要使用它,我加入它對我的一個觀點類如下:

public class FilesView extends ViewWithUiHandlers<FilesUiHandlers> implements FilesPresenter.MyView { 
    interface Binder extends UiBinder<Widget, FilesView> {} 
    private static FilesViewUiBinder uiBinder = GWT.create(FilesViewUiBinder.class); 
    interface FilesViewUiBinder extends UiBinder<Widget, FilesView> {} 
    @UiField 
    MaterialRow row; 
    public FilesView() { 
    initWidget(uiBinder.createAndBindUi(this)); 
    row.add(new HorizontalTabs()); 
    } 

<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent"> 
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder" 
     xmlns:g="urn:import:com.google.gwt.user.client.ui" xmlns:m="urn:import:gwt.material.design.client.ui"> 
    <g:HTMLPanel> 
     <h2>Your files</h2> 
     <m:MaterialRow> 
      <m:MaterialRow ui:field="row"> 
      </m:MaterialRow> 
     </m:MaterialRow> 
    </g:HTMLPanel> 
</ui:UiBinder> 

Everythink編譯好。但是當我嘗試進入包含這個小部件的視圖時會出現問題。

這裏是堆棧跟蹤:

SEVERE: Exception caught: Exception caught: Exception caught: Exception caught: Exception caught: Exception caught: (TypeError) : Cannot read property 'hash' of undefinedcom.google.gwt.user.client.ui.AttachDetachException: Exception caught: Exception caught: Exception caught: Exception caught: Exception caught: Exception caught: (TypeError) : Cannot read property 'hash' of undefined 
    at Unknown.fillInStackTrace_0_g$([email protected]:8443) 
    at Unknown.Throwable_3_g$([email protected]:8398) 
    at Unknown.Exception_3_g$([email protected]:8541) 
    at Unknown.RuntimeException_3_g$([email protected]:8582) 
    at Unknown.UmbrellaException_3_g$([email protected]:36497) 
    at Unknown.UmbrellaException_5_g$([email protected]:36558) 
    at Unknown.AttachDetachException_1_g$([email protected]:55009) 
    at Unknown.tryCommand_1_g$([email protected]:55065) 
    at Unknown.doAttachChildren_1_g$([email protected]:54662) 
    at Unknown.onAttach_2_g$([email protected]:54494) 
    at Unknown.setParent_2_g$([email protected]:54590) 
    at Unknown.adopt_0_g$([email protected]:54649) 
    at Unknown.add_14_g$([email protected]:54707) 
    at Unknown.add_13_g$([email protected]:54700) 
    at Unknown.add_66_g$([email protected]:77215) 
    at Unknown.add_11_g$([email protected]:54637) 
    at Unknown.add_65_g$([email protected]:77211) 
    at Unknown.setPanelContent_0_g$([email protected]:114885) 
    at Unknown.setInSlot_7_g$([email protected]:107982) 
    at Unknown.setInSlot_1_g$([email protected]:73077) 
    at Unknown.setInSlot_0_g$([email protected]:73066) 
    at Unknown.execute_27_g$([email protected]:76290) 
    at Unknown.$executeScheduled_0_g$([email protected]:11660) 
    at Unknown.runScheduledTasks_0_g$([email protected]:11382) 
    at Unknown.flushPostEventPumpCommands_0_g$([email protected]:11474) 
    at Unknown.execute_5_g$([email protected]:11613) 
    at Unknown.execute_4_g$([email protected]:11350) 
    at Unknown.apply_0_g$([email protected]:10845) 
    at Unknown.entry0_0_g$([email protected]:10901) 
    at Unknown.anonymous([email protected]:10881) 
    at Unknown.callback_0_g$([email protected]:11401) 
Caused by: com.google.gwt.user.client.ui.AttachDetachException: Exception caught: Exception caught: 

我認爲這是愚蠢的問題,但我真的不能找到解決辦法。請幫忙。

也許有辦法找到原因,但對我來說,當我需要找到運行時異常時,很難調試GWT應用程序。

+0

你的小部件在我的最後工作都很好(沒有gwtp類),對我來說沒有任何問題。嘗試調試您的應用程序以查找導致問題的文件。 – Ajax

回答

0

可能是這種情況,我沒有任何公共getter和setter和構造函數的widget模型對象。但現在我不確定。它開始工作。

相關問題