Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
AW: [birt-dev] Howto Access Java Objects for a Chart or Table

Hi,
now I'm able to access JavaObjects out of the Scripting DataSource, but I got another error when I try to addit into the Report.
(ECLIPSE-ENV) Could not find dsp impl for org.eclipse.birt.chart.model.type.impl.LineSeriesImpl
or if i try the PieChart it is the same but with
(ECLIPSE-ENV) Could not find dsp impl for org.eclipse.birt.chart.model.type.impl.PieSeriesImpl

I do not understand this logging message.

----- Urspr√ľngliche Mail ----
Von: Hannes Tribus <hannes_tribus@xxxxxxxx>
An: birt-dev@xxxxxxxxxxx
Gesendet: Dienstag, den 20. Mai 2008, 22:21:00 Uhr
Betreff: [birt-dev] Howto Access Java Objects for a Chart or Table

Hi,
i took the example I found in the Mailinglist added by Markus Schlautmann, but I'm not able to call methods from the Java Object "dataProvider".
I've registered it in the ContextMap, but the ScriptSource is not able to find it.
Do I have to copy the Class-file into the WEB-INF folder?

Thx
Hannes

design = engine.openReportDesign(designHandle);
            IRunAndRenderTask task = engine.createRunAndRenderTask(design);
            RenderOption renderContext = new RenderOption();

            HashMap<String, Object> contextMap = new HashMap<String, Object>();
            IRenderOption options;
            if (output == "html") {
                contextMap.put(EngineConstants.APPCONTEXT_HTML_RENDER_CONTEXT, renderContext);
                contextMap.put("dataProvider", CreateReportEngine._dp);
                options = new HTMLRenderOption();

                ((HTMLRenderOption) options).setImageDirectory("output/image");
                ((HTMLRenderOption) options).setHtmlPagination(false);
                ((HTMLRenderOption) options).setHtmlRtLFlag(false);
                ((HTMLRenderOption) options).setEmbeddable(false);

                options.setOutputFormat(PDFRenderOption.OUTPUT_FORMAT_HTML);
            } else {
                contextMap.put(EngineConstants.APPCONTEXT_PDF_RENDER_CONTEXT, renderContext);
                contextMap.put("dataProvider", CreateReportEngine._dp);
                options = new PDFRenderOption();
                options.setSupportedImageFormats("PNG;GIF;JPG;BMP");
                options.setOption(IPDFRenderOption.FIT_TO_PAGE, new Boolean(true));
                options.setOption(IPDFRenderOption.PAGEBREAK_PAGINATION_ONLY, new Boolean(true));
                options.setOutputFormat(PDFRenderOption.OUTPUT_FORMAT_PDF);
                if (file == null) {
                    return null;
                }

            }
            if (file != null) {
                options.setOutputFileName(file.getAbsolutePath());
            }
            task.setAppContext(contextMap);
            // options.setOutputFormat(output);
            options.setOutputStream(bos);
            task.setRenderOption(options);

            // run the report and destroy the engine
            task.run();
            task.close();
            engine.destroy();

The ErrorMessage in the Log
WARNUNG: A BIRT exception occurred: Error evaluating _javascript_ _expression_. Script engine error: TypeError: Cannot call method "getyValues" of null (DataSet[ds].__bm_OPEN#2)
 Script source: DataSet[ds].__bm_OPEN, line: 1, text:
__bm_OPEN(). See next exception for more information.
Error evaluating _javascript_ _expression_. Script engine error: TypeError: Cannot call method "getyValues" of null (DataSet[ds].__bm_OPEN#2)
 Script source: DataSet[ds].__bm_OPEN, line: 1, text:
__bm_OPEN()
org.eclipse.birt.data.engine.core.DataException: A BIRT exception occurred: Error evaluating _javascript_ _expression_. Script engine error: TypeError: Cannot call method "getyValues" of null (DataSet[ds].__bm_OPEN#2)
 Script source: DataSet[ds].__bm_OPEN, line: 1, text:
__bm_OPEN(). See next exception for more information.
Error evaluating _javascript_ _expression_. Script engine error: TypeError: Cannot call method "getyValues" of null (DataSet[ds].__bm_OPEN#2)
 Script source: DataSet[ds]...

The Source:
void buildDataSet(DataProviderChart dataProvider) {
        try {
            System.out.println("starting buildDataSet() method");

            ScriptDataSetHandle dsHandle = _efactory.newScriptDataSet("ds");
            dsHandle.setDataSource("Data Source");
                   
            dsHandle.setOpen("var dataProvider=reportContext.getAppContext().get(\"dataProvider\");"
                    + "data = "" \n"
                    + "data2 = dataProvider.getxValues(); \n "
                    + "totalrows = data.size(); \n" + "currentrow = 1;\n");

            dsHandle.setFetch("if(currentrow >= totalrows) \n" + "{return(false);} \n" + "var favrow = data.get(currentrow); \n" + "row[\"abc0\"] = favrow; \n" + "var favrow2 = data2.get(currentrow); \n" + "row[\"cba0\"] = favrow2 \n;" + "currentrow = currentrow + 1; \n" + "return(true); \n");

            dsHandle.setClose("data = "" \n data2 = null; \n");

            PropertyHandle computedSet = dsHandle.getPropertyHandle(ScriptDataSetHandle.RESULT_SET_PROP);
            ResultSetColumn resultColumn = StructureFactory.createResultSetColumn();

            resultColumn = StructureFactory.createResultSetColumn();
            resultColumn.setPosition(1);
            resultColumn.setColumnName("abc0");
            resultColumn.setDataType("float");
            computedSet.addItem(resultColumn);

            resultColumn = StructureFactory.createResultSetColumn();
            resultColumn.setPosition(2);
            resultColumn.setColumnName("cba0");
            resultColumn.setDataType("string");
            computedSet.addItem(resultColumn);

            _design.getDataSets().add(dsHandle);

            System.out.println("Finished buildDataSet() method");
            System.out.println("");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }




Gesendet von Yahoo! Mail.
Dem pfiffigeren Posteingang.


Gesendet von Yahoo! Mail.
Dem pfiffigeren Posteingang.

Back to the top