无法在smartgwt中的Canvas(Window)上渲染Fusion图表

时间:2015-11-05 06:36:22

标签: canvas gwt widget smartgwt fusioncharts

        package com.test.client.modules.grid;

        import com.google.gwt.core.client.GWT;
        import com.smartgwt.client.widgets.Canvas;
        import com.smartgwt.client.widgets.HTMLFlow;
        import com.smartgwt.client.widgets.Window;
        import com.smartgwt.client.widgets.events.CloseClickEvent;
        import com.smartgwt.client.widgets.events.CloseClickHandler;
        import com.smartgwt.client.widgets.grid.ListGridField;
        import com.smartgwt.client.widgets.grid.events.CellClickEvent;
        import com.smartgwt.client.widgets.grid.events.CellClickHandler;
        import com.smartgwt.client.widgets.layout.VLayout;

        public class GroupManagement{

            private GroupManagementGrid groupManagementGrid;
            private GroupManagementDS groupManagementDS;
            private VLayout groupManagementVLayout;
            private final GreetingServiceAsync service = GWT.create(GreetingService.class);
            int roleID;


            public Canvas loadGUI() {

                Canvas groupManagementLayout = new Canvas();
                groupManagementLayout.setWidth100();
                groupManagementLayout.setHeight100();
                groupManagementLayout.setShowEdges(false);
                groupManagementLayout.addChild(loadGroupManagementScreen());
                return groupManagementLayout;
            }

            public VLayout loadGroupManagementScreen() {

                groupManagementDS = new GroupManagementDS("MANAGE_GROUPS");
                groupManagementGrid = new GroupManagementGrid(groupManagementDS);

                groupManagementGrid.getPaginationGrid().addCellClickHandler(new CellClickHandler() {

                    @Override
                    public void onCellClick(CellClickEvent event) {
                        int colNum = event.getColNum();

                        ListGridField field = groupManagementGrid.getPaginationGrid().getField(colNum);
                        String fieldName = field.getName();

                        if (fieldName.equals("ASSIGN_MODULE_ACCESS")) {

                            final Window winNDC = new Window();
                            winNDC.setWidth100();
                            winNDC.setHeight100();
                            winNDC.setTitle("Charts");
                            winNDC.setShowMinimizeButton(false);
                            winNDC.setIsModal(true);
                            winNDC.setShowModalMask(true);
                            winNDC.centerInPage();
                            winNDC.addCloseClickHandler(new CloseClickHandler() {
                                public void onCloseClick(CloseClickEvent event) {
                                    winNDC.destroy();
                                }
                            });

                            final HTMLFlow contentHTML = new HTMLFlow();
                            //contentHTML.setContentsType(ContentsType.FRAGMENT).
                            contentHTML.setContents("<!doctype html>"+
                            "<html>"+
                            "<head>"+
                            "<meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\">" + 
                            "<link type=\"text/css\" rel=\"stylesheet\" href=\"Charts.css\">" +
                            "<title>Fusion Charts</title>" +
                            "<script type=\"text/javascript\" language=\"javascript\" src=\"test/test.nocache.js\"></script>" +
                            "<script type=\"text/javascript\" src=\"fusion/FusionCharts.js\"> </script>" +
                            "</head>" +
                            "<body>"+ 
                            "<noscript>" +
                            "<div style=\"width: 22em; position: absolute; left: 50%; margin-left: -11em; color: red; background-color: white; border: 1px solid red; padding: 4px; font-family: sans-serif\"> Your web browser must have JavaScript enabled in order for thisapplication to display correctly.</div>" +
                            "</noscript>" +
                            "<h1>Fusion Charts</h1>" +
                            "<table align=\"center\">" +
                            "<tr>" + 
                                "<td>" + 
                                    "<table>" + 
                                        "<tr>" +
                                            "<td id=\"chartDiv\">FusionCharts XT will load here!</td>" +
                                        "</tr>" +
                                    "</table>" +
                                "</td>" +
                            "</table>" +
                            "<script type=\"text/javascript\">" +
                             "var chart = new FusionCharts(\"fusion/Line.swf\",\"myChartId\", \"900\", \"300\", \"0\", \"0\");" +
                             "chart.setDataURL(\"Charts.xml\");" +
                                "chart.setTransparent(true);" +
                             "chart.render(\"chartDiv\");" +
                             "</script>" +
                            "</body>" +
                            "</html>");

                            winNDC.addItem(contentHTML);
                            winNDC.show();
                        }
                    }
                });
                groupManagementVLayout = new VLayout();
                groupManagementVLayout.setWidth100();
                groupManagementVLayout.setHeight100();

                groupManagementVLayout.addMember(groupManagementGrid.getPaginationGrid());

                GroupData groupData=new GroupData(service,groupManagementDS);
                groupData.getAllGroupDetails();

                return groupManagementVLayout;
            }

        }

注意: 我想在smartgwt中的窗口上渲染fusionChart我有静态xml,名为charts.xml,我创建了html页面运行时,我想在td id = chartDiv中创建html页面创建运行时的图表

0 个答案:

没有答案