簡體   English   中英

GWT DataGrid錯誤:追加到“ SimplePanel”時,未定義“ com.google.gwt.user.client.ui.IsWidget”

[英]GWT DataGrid error: `com.google.gwt.user.client.ui.IsWidget is not defined` while appending to `SimplePanel`

我想在我的項目中使用GWT DataGrid小部件 我什至在這里找到了最簡單的解決方案。 不幸的是,我遇到一個錯誤: Lcom_google_gwt_user_client_ui_IsWidget_2_classLit_0_g$ is not defined 我注意到只有當我有以下代碼行時,才會發生這種情況: dataGrid.add(table); 其中dataGrid變量為:

@UiField
SimplePanel dataGrid;

變量是:

DataGrid<Address> table = new DataGrid<Address>();

這是來自Web瀏覽器控制台(Google Chrome)的完整堆棧跟蹤:

Tue Mar 15 08:54:41 GMT+100 2016 com.google.gwt.logging.client.LogConfiguration
SEVERE: Exception caught: Exception caught: Exception caught: Exception caught: (ReferenceError) : Lcom_google_gwt_user_client_ui_IsWidget_2_classLit_0_g$ is not definedcom.google.gwt.user.client.ui.AttachDetachException: Exception caught: Exception caught: Exception caught: Exception caught: (ReferenceError) : Lcom_google_gwt_user_client_ui_IsWidget_2_classLit_0_g$ is not defined
    at Unknown.fillInStackTrace_0_g$(cms-0.js@3:8683)
    at Unknown.Throwable_3_g$(cms-0.js@8:8638)
    at Unknown.Exception_3_g$(cms-0.js@18:8781)
    at Unknown.RuntimeException_3_g$(cms-0.js@18:8822)
    at Unknown.UmbrellaException_3_g$(cms-0.js@25:36781)
    at Unknown.UmbrellaException_5_g$(cms-0.js@26:36842)
    at Unknown.AttachDetachException_1_g$(cms-0.js@26:62116)
    at Unknown.tryCommand_1_g$(cms-0.js@11:62172)
    at Unknown.doAttachChildren_1_g$(cms-0.js@3:61692)
    at Unknown.onAttach_2_g$(cms-0.js@8:53199)
    at Unknown.setParent_2_g$(cms-0.js@12:53295)
    at Unknown.adopt_0_g$(cms-0.js@14:61679)
    at Unknown.add_14_g$(cms-0.js@8:61737)
    at Unknown.add_13_g$(cms-0.js@8:61730)
    at Unknown.add_66_g$(cms-0.js@8:89357)
    at Unknown.add_11_g$(cms-0.js@8:61667)
    at Unknown.add_65_g$(cms-0.js@43:89353)
    at Unknown.setPanelContent_0_g$(cms-0.js@54:127158)
    at Unknown.setInSlot_7_g$(cms-0.js@25:119945)
    at Unknown.setInSlot_1_g$(cms-0.js@25:85174)
    at Unknown.setInSlot_0_g$(cms-0.js@8:85163)
    at Unknown.execute_27_g$(cms-0.js@30:88416)
    at Unknown.$executeScheduled_0_g$(cms-0.js@40:11900)
    at Unknown.runScheduledTasks_0_g$(cms-0.js@9:11622)
    at Unknown.flushPostEventPumpCommands_0_g$(cms-0.js@5:11714)
    at Unknown.execute_5_g$(cms-0.js@22:11853)
    at Unknown.execute_4_g$(cms-0.js@19:11590)
    at Unknown.apply_0_g$(cms-0.js@28:11085)
    at Unknown.entry0_0_g$(cms-0.js@16:11141)
    at Unknown.anonymous(cms-0.js@14:11121)
    at Unknown.callback_0_g$(cms-0.js@45:11641)
Caused by: com.google.gwt.user.client.ui.AttachDetachException: Exception caught: Exception caught: Exception caught: (ReferenceError) : Lcom_google_gwt_user_client_ui_IsWidget_2_classLit_0_g$ is not defined
    at Unknown.fillInStackTrace_0_g$(cms-0.js@3:8683)
    at Unknown.Throwable_3_g$(cms-0.js@8:8638)
    at Unknown.Exception_3_g$(cms-0.js@18:8781)
    at Unknown.RuntimeException_3_g$(cms-0.js@18:8822)
    at Unknown.UmbrellaException_3_g$(cms-0.js@25:36781)
    at Unknown.UmbrellaException_5_g$(cms-0.js@26:36842)
    at Unknown.AttachDetachException_1_g$(cms-0.js@26:62116)
    at Unknown.tryCommand_1_g$(cms-0.js@11:62172)
    at Unknown.doAttachChildren_1_g$(cms-0.js@3:61692)
    at Unknown.onAttach_2_g$(cms-0.js@8:53199)
    at Unknown.execute_9_g$(cms-0.js@10:62200)
    at Unknown.tryCommand_1_g$(cms-0.js@14:62156)
    at Unknown.doAttachChildren_1_g$(cms-0.js@3:61692)
    at Unknown.onAttach_2_g$(cms-0.js@8:53199)
    at Unknown.setParent_2_g$(cms-0.js@12:53295)
    at Unknown.adopt_0_g$(cms-0.js@14:61679)
    at Unknown.add_14_g$(cms-0.js@8:61737)
    at Unknown.add_13_g$(cms-0.js@8:61730)
    at Unknown.add_66_g$(cms-0.js@8:89357)
    at Unknown.add_11_g$(cms-0.js@8:61667)
    at Unknown.add_65_g$(cms-0.js@43:89353)
    at Unknown.setPanelContent_0_g$(cms-0.js@54:127158)
    at Unknown.setInSlot_7_g$(cms-0.js@25:119945)
    at Unknown.setInSlot_1_g$(cms-0.js@25:85174)
    at Unknown.setInSlot_0_g$(cms-0.js@8:85163)
    at Unknown.execute_27_g$(cms-0.js@30:88416)
    at Unknown.$executeScheduled_0_g$(cms-0.js@40:11900)
    at Unknown.runScheduledTasks_0_g$(cms-0.js@9:11622)
    at Unknown.flushPostEventPumpCommands_0_g$(cms-0.js@5:11714)
    at Unknown.execute_5_g$(cms-0.js@22:11853)
    at Unknown.execute_4_g$(cms-0.js@19:11590)
    at Unknown.apply_0_g$(cms-0.js@28:11085)
    at Unknown.entry0_0_g$(cms-0.js@16:11141)
    at Unknown.anonymous(cms-0.js@14:11121)
    at Unknown.callback_0_g$(cms-0.js@45:11641)
Caused by: com.google.gwt.user.client.ui.AttachDetachException: Exception caught: Exception caught: (ReferenceError) : Lcom_google_gwt_user_client_ui_IsWidget_2_classLit_0_g$ is not defined
    at Unknown.fillInStackTrace_0_g$(cms-0.js@3:8683)
    at Unknown.Throwable_3_g$(cms-0.js@8:8638)
    at Unknown.Exception_3_g$(cms-0.js@18:8781)
    at Unknown.RuntimeException_3_g$(cms-0.js@18:8822)
    at Unknown.UmbrellaException_3_g$(cms-0.js@25:36781)
    at Unknown.UmbrellaException_5_g$(cms-0.js@26:36842)
    at Unknown.AttachDetachException_1_g$(cms-0.js@26:62116)
    at Unknown.tryCommand_1_g$(cms-0.js@11:62172)
    at Unknown.doAttachChildren_1_g$(cms-0.js@3:61692)
    at Unknown.onAttach_2_g$(cms-0.js@8:53199)
    at Unknown.execute_9_g$(cms-0.js@10:62200)
    at Unknown.tryCommand_1_g$(cms-0.js@14:62156)
    at Unknown.doAttachChildren_1_g$(cms-0.js@3:61692)
    at Unknown.onAttach_2_g$(cms-0.js@8:53199)
    at Unknown.execute_9_g$(cms-0.js@10:62200)
    at Unknown.tryCommand_1_g$(cms-0.js@14:62156)
    at Unknown.doAttachChildren_1_g$(cms-0.js@3:61692)
    at Unknown.onAttach_2_g$(cms-0.js@8:53199)
    at Unknown.setParent_2_g$(cms-0.js@12:53295)
    at Unknown.adopt_0_g$(cms-0.js@14:61679)
    at Unknown.add_14_g$(cms-0.js@8:61737)
    at Unknown.add_13_g$(cms-0.js@8:61730)
    at Unknown.add_66_g$(cms-0.js@8:89357)
    at Unknown.add_11_g$(cms-0.js@8:61667)
    at Unknown.add_65_g$(cms-0.js@43:89353)
    at Unknown.setPanelContent_0_g$(cms-0.js@54:127158)
    at Unknown.setInSlot_7_g$(cms-0.js@25:119945)
    at Unknown.setInSlot_1_g$(cms-0.js@25:85174)
    at Unknown.setInSlot_0_g$(cms-0.js@8:85163)
    at Unknown.execute_27_g$(cms-0.js@30:88416)
    at Unknown.$executeScheduled_0_g$(cms-0.js@40:11900)
    at Unknown.runScheduledTasks_0_g$(cms-0.js@9:11622)
    at Unknown.flushPostEventPumpCommands_0_g$(cms-0.js@5:11714)
    at Unknown.execute_5_g$(cms-0.js@22:11853)
    at Unknown.execute_4_g$(cms-0.js@19:11590)
    at Unknown.apply_0_g$(cms-0.js@28:11085)
    at Unknown.entry0_0_g$(cms-0.js@16:11141)
    at Unknown.anonymous(cms-0.js@14:11121)
    at Unknown.callback_0_g$(cms-0.js@45:11641)
Caused by: com.google.gwt.user.client.ui.AttachDetachException: Exception caught: (ReferenceError) : Lcom_google_gwt_user_client_ui_IsWidget_2_classLit_0_g$ is not defined
    at Unknown.fillInStackTrace_0_g$(cms-0.js@3:8683)
    at Unknown.Throwable_3_g$(cms-0.js@8:8638)
    at Unknown.Exception_3_g$(cms-0.js@18:8781)
    at Unknown.RuntimeException_3_g$(cms-0.js@18:8822)
    at Unknown.UmbrellaException_3_g$(cms-0.js@25:36781)
    at Unknown.UmbrellaException_5_g$(cms-0.js@26:36842)
    at Unknown.AttachDetachException_1_g$(cms-0.js@26:62116)
    at Unknown.tryCommand_1_g$(cms-0.js@11:62172)
    at Unknown.doAttachChildren_1_g$(cms-0.js@3:61692)
    at Unknown.onAttach_2_g$(cms-0.js@8:53199)
    at Unknown.onAttach_14_g$(cms-0.js@46:67161)
    at Unknown.onAttach_4_g$(cms-0.js@20:53405)
    at Unknown.execute_9_g$(cms-0.js@10:62200)
    at Unknown.tryCommand_1_g$(cms-0.js@14:62156)
    at Unknown.doAttachChildren_1_g$(cms-0.js@3:61692)
    at Unknown.onAttach_2_g$(cms-0.js@8:53199)
    at Unknown.execute_9_g$(cms-0.js@10:62200)
    at Unknown.tryCommand_1_g$(cms-0.js@14:62156)
    at Unknown.doAttachChildren_1_g$(cms-0.js@3:61692)
    at Unknown.onAttach_2_g$(cms-0.js@8:53199)
    at Unknown.execute_9_g$(cms-0.js@10:62200)
    at Unknown.tryCommand_1_g$(cms-0.js@14:62156)
    at Unknown.doAttachChildren_1_g$(cms-0.js@3:61692)
    at Unknown.onAttach_2_g$(cms-0.js@8:53199)
    at Unknown.setParent_2_g$(cms-0.js@12:53295)
    at Unknown.adopt_0_g$(cms-0.js@14:61679)
    at Unknown.add_14_g$(cms-0.js@8:61737)
    at Unknown.add_13_g$(cms-0.js@8:61730)
    at Unknown.add_66_g$(cms-0.js@8:89357)
    at Unknown.add_11_g$(cms-0.js@8:61667)
    at Unknown.add_65_g$(cms-0.js@43:89353)
    at Unknown.setPanelContent_0_g$(cms-0.js@54:127158)
    at Unknown.setInSlot_7_g$(cms-0.js@25:119945)
    at Unknown.setInSlot_1_g$(cms-0.js@25:85174)
    at Unknown.setInSlot_0_g$(cms-0.js@8:85163)
    at Unknown.execute_27_g$(cms-0.js@30:88416)
    at Unknown.$executeScheduled_0_g$(cms-0.js@40:11900)
    at Unknown.runScheduledTasks_0_g$(cms-0.js@9:11622)
    at Unknown.flushPostEventPumpCommands_0_g$(cms-0.js@5:11714)
    at Unknown.execute_5_g$(cms-0.js@22:11853)
    at Unknown.execute_4_g$(cms-0.js@19:11590)
    at Unknown.apply_0_g$(cms-0.js@28:11085)
    at Unknown.entry0_0_g$(cms-0.js@16:11141)
    at Unknown.anonymous(cms-0.js@14:11121)
    at Unknown.callback_0_g$(cms-0.js@45:11641)
Caused by: com.google.gwt.core.client.JavaScriptException: (ReferenceError) : Lcom_google_gwt_user_client_ui_IsWidget_2_classLit_0_g$ is not defined
    at Unknown.doAttachChildren_5_g$(cms-0.js@125:63399)
    at Unknown.onAttach_2_g$(cms-0.js@8:53199)
    at Unknown.onAttach_12_g$(cms-0.js@46:63237)
    at Unknown.onAttach_13_g$(cms-0.js@46:63523)
    at Unknown.execute_9_g$(cms-0.js@10:62200)
    at Unknown.tryCommand_1_g$(cms-0.js@14:62156)
    at Unknown.doAttachChildren_1_g$(cms-0.js@3:61692)
    at Unknown.onAttach_2_g$(cms-0.js@8:53199)
    at Unknown.onAttach_14_g$(cms-0.js@46:67161)
    at Unknown.onAttach_4_g$(cms-0.js@20:53405)

這是視圖類:

import java.util.Arrays;
import java.util.List;

import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.cellview.client.DataGrid;
import com.google.gwt.user.cellview.client.HasKeyboardSelectionPolicy.KeyboardSelectionPolicy;
import com.google.gwt.user.cellview.client.TextColumn;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.SimplePanel;
import com.google.gwt.user.client.ui.Widget;
import com.google.gwt.view.client.SelectionChangeEvent;
import com.google.gwt.view.client.SingleSelectionModel;
import com.gwtplatform.mvp.client.ViewWithUiHandlers;

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
    SimplePanel dataGrid;

    public FilesView() {
    initWidget(uiBinder.createAndBindUi(this));
    loadTable();
    }

    /**
     * A simple data type that represents an Address.
     */
    private static class Address {
    private final String houseNumber;
    private final String streetName;
    private final String county;
    private final String postCode;
    private final String country;

    public Address(String houseNumber, String streetName, String county, String postCode, String country) {
        this.houseNumber = houseNumber;
        this.streetName = streetName;
        this.county = county;
        this.postCode = postCode;
        this.country = country;
    }
    }

    /*
     * The list of data to display.
     */
    private static final List<Address> ADDRESS = Arrays.asList(new Address("123", "Lloyds Road", "Middlesex", "TE0 6NB", "United Kingdom"), new Address("456", "Oxford Street", "Oxford", "LK9 0CV",
        "United Kingdom"));

    public void loadTable() {
    DataGrid<Address> table = new DataGrid<Address>();
    table.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.ENABLED);

    TextColumn<Address> houseNumber = new TextColumn<Address>() {
        @Override
        public String getValue(Address object) {
        return object.houseNumber;
        }
    };
    table.addColumn(houseNumber, "House Number");

    TextColumn<Address> streetName = new TextColumn<Address>() {
        @Override
        public String getValue(Address object) {
        return object.streetName;
        }
    };
    table.addColumn(streetName, "Street Name");

    TextColumn<Address> county = new TextColumn<Address>() {
        @Override
        public String getValue(Address object) {
        return object.county;
        }
    };
    table.addColumn(county, "County");

    TextColumn<Address> postCode = new TextColumn<Address>() {
        @Override
        public String getValue(Address object) {
        return object.postCode;
        }
    };
    table.addColumn(postCode, "Post Code");

    TextColumn<Address> country = new TextColumn<Address>() {
        @Override
        public String getValue(Address object) {
        return object.country;
        }
    };
    table.addColumn(country, "Country");

    // Add a selection model to handle user selection.
    final SingleSelectionModel<Address> selectionModel = new SingleSelectionModel<Address>();
    table.setSelectionModel(selectionModel);
    selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
        @Override
        public void onSelectionChange(SelectionChangeEvent event) {
        Address selected = selectionModel.getSelectedObject();
        if (selected != null) {
            Window.alert("You selected: " + selected.houseNumber + " " + selected.streetName + " " + selected.county + " " + selected.postCode + " " + selected.country);
        }
        }
    });
    table.setRowCount(ADDRESS.size(), true);
    table.setRowData(0, ADDRESS);
    table.setWidth("100%");
    // SimpleLayoutPanel slp = new SimpleLayoutPanel();

    dataGrid.add(table);
    // Add it to the root panel.
    // RootLayoutPanel.get().add(slp);
    }

}

和活頁夾視圖類:

<!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>
        <g:HTMLPanel>
            <h2>Your files</h2>
            <g:SimplePanel ui:field="dataGrid" />
        </g:HTMLPanel>
    </m:MaterialRow>
</ui:UiBinder>

演示者沒有做任何特別的事情。

我使用GWT 2.7

請幫忙。

這很奇怪,但足以:

  1. 清理並安裝項目。
  2. 重新啟動超級開發模式

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM