Unable to load module entry point in GWT/GXT Proje

2019-08-31 17:40发布

问题:

I am working on GWT/GXT

I trying to create radar Chart Here is the Code

public class Test implements EntryPoint {

    public static boolean isExplorer() {
        String test = Window.Location.getPath();

        if (test.indexOf("pages") != -1) {
            return false;
        }
        return true;
    }    
    @Override
    public void onModuleLoad() {

        RootPanel.get().add(new ChartExmaple());
    }    
}

public class ChartExmaple extends LayoutContainer {

    private ChartModelExample example = new RadarChart();
    private Command updateCmd;

    @Override
    protected void onRender(Element parent, int index) {
        super.onRender(parent, index);
        ContentPanel cp = new ContentPanel();
        cp.setHeading("Charts Gallery");
        cp.setFrame(true);
        cp.setSize(700, 350);
        cp.setLayout(new BorderLayout());

        BorderLayoutData centerData = new BorderLayoutData(LayoutRegion.CENTER);
        centerData.setMargins(new Margins(0, 5, 0, 0));

        cp.add(getChart(), centerData);

        add(cp, new MarginData(20));

    }       
    private LayoutContainer getChart() {
        FieldSet fs = new FieldSet();
        fs.setHeading("Opera Star");
        fs.setLayout(new FitLayout());

        String url = !Test.isExplorer() ? "../../" : "";
        url += "gxt/chart/open-flash-chart.swf";

        final Chart chart = new Chart(url);
        chart.setBorders(true);
        fs.add(chart, new FitData(0, 0, 20, 0));
        updateCmd = new Command() {
            public void execute() {
                chart.setChartModel(example.getChartModel(5));
            }
        };

        return fs;
    }

}

RadarChart.Java

    public class RadarChart implements ChartModelExample {

    @Override
    public ChartModel getChartModel(int segments) {
        ChartModel cm = new ChartModel("Popularity",
                "font-size: 12px; text-align: left;");
        cm.setBackgroundColour("#f0f0f0");
        RadarAxis ra = new RadarAxis();
        ra.setMax(segments + 1);
        ra.setStroke(2);
        ra.setColour("#A1D4B5");
        ra.setGridColour("#C0DEBF");
        ra.setSpokeLabels("Ext", "Web", "Java", "AJAX", "PHP");
        cm.setRadarAxis(ra);
        AreaChart area = new AreaChart();
        area.setFillAlpha(0.3f);
        area.setColour("#ff9900");
        area.setFillColour("#ff6600");
        area.setLoop(true);
        area.addValues(segments);
        area.addValues(Random.nextInt(segments + 1));
        area.addValues(Random.nextInt(segments + 1));
        area.addValues(Random.nextInt(segments + 1));
        area.addValues(Random.nextInt(segments + 1));
        cm.addChartConfig(area);
        return cm;
    }
}

Error

[ERROR] [test] - Unable to load module entry point class test.client.Test (see associated exception for details)
[ERROR] [test] - Failed to load module 'test' from user agent 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.116 Safari/537.36' at 127.0.0.1:58087


19:10:32.887 [ERROR] [test] Unable to load module entry point class test.client.Test (see associated exception for details)
com.google.gwt.core.client.JavaScriptException: (TypeError) @com.extjs.gxt.ui.client.widget.ComponentHelper::doAttachNative(Lcom/google/gwt/user/client/ui/Widget;)([Java object: com.extjs.gxt.ui.client.widget.ContentPanel@676012820]): Cannot read property 'embedSWF' of undefined
    at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:249)
    at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
    at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:571)
    at com.google.gwt.dev.shell.ModuleSpace.invokeNativeVoid(ModuleSpace.java:299)
    at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeVoid(JavaScriptHost.java:107)
    at com.extjs.gxt.ui.client.widget.ComponentHelper.doAttachNative(ComponentHelper.java)
    at com.extjs.gxt.ui.client.widget.ComponentHelper.doAttach(ComponentHelper.java:21)
    at com.extjs.gxt.ui.client.widget.Container.attachChildren(Container.java:635)
    at com.extjs.gxt.ui.client.widget.Container.onLayoutExcecuted(Container.java:497)
    at com.extjs.gxt.ui.client.widget.Container$1.handleEvent(Container.java:586)
    at com.extjs.gxt.ui.client.widget.Container$1.handleEvent(Container.java:1)
    at com.extjs.gxt.ui.client.event.BaseObservable.callListener(BaseObservable.java:178)
    at com.extjs.gxt.ui.client.event.BaseObservable.fireEvent(BaseObservable.java:86)
    at com.extjs.gxt.ui.client.widget.Layout.layout(Layout.java:116)
    at com.extjs.gxt.ui.client.widget.Container.doLayout(Container.java:351)
    at com.extjs.gxt.ui.client.widget.Container.layout(Container.java:443)
    at com.extjs.gxt.ui.client.widget.LayoutContainer.layout(LayoutContainer.java:246)
    at com.extjs.gxt.ui.client.widget.Container.layout(Container.java:426)
    at com.extjs.gxt.ui.client.widget.LayoutContainer.layout(LayoutContainer.java:241)
    at com.extjs.gxt.ui.client.widget.Container.onAttach(Container.java:479)
    at com.google.gwt.user.client.ui.Widget.setParent(Widget.java:475)
    at com.google.gwt.user.client.ui.Panel.adopt(Panel.java:127)
    at com.google.gwt.user.client.ui.ComplexPanel.add(ComplexPanel.java:97)
    at com.google.gwt.user.client.ui.AbsolutePanel.add(AbsolutePanel.java:97)
    at test.client.Test.onModuleLoad(Test.java:24)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at com.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:406)
    at com.google.gwt.dev.shell.OophmSessionHandler.loadModule(OophmSessionHandler.java:200)
    at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:526)
    at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:364)
    at java.lang.Thread.run(Unknown Source)

Edited

public interface ChartModelExample {
    public ChartModel getChartModel(int segments);

}

回答1:

I have included swfobject.js in my HTML page and the error is gone.

I have downloaded it from gxt/samples/public/flash/swfobject.js


Make sure you have included the swfobject.js and the location of open-flash-chart.swf is correct.

For more info follow this link till the last section.



标签: gwt gwt2 gxt