Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » BIRT » Call Java method in Birt Report(I would like to call a java method in rptdesign file in )
Call Java method in Birt Report [message #1829542] Mon, 06 July 2020 16:17
Krina Mehta is currently offline Krina MehtaFriend
Messages: 1
Registered: July 2020
Junior Member
I am having requirement of calling a JAVA method in Birt report , rptdesign file. I followed the example given in below URL.
https://download.eclipse.org/birt/downloads/examples/scripting/scripteddatasource/javacode/

JAVA class URL:
https://download.eclipse.org/birt/downloads/examples/scripting/scripteddatasource/javacode/SimpleClass.java

rptdesign file URL:
https://download.eclipse.org/birt/downloads/examples/scripting/scripteddatasource/reports/ScriptedDatasourceExampleAfter.rptdesign

As given in this example, I called my java class exactly the same way as below.
1. <method name="open"><![CDATA[favoritesClass = new Packages.SampleRowUpdater();
favorites = favoritesClass.readData(dataSetRow["LASTUPDATEDUSER"]);
totalrows = favorites.size();
currentrow = 0;]]></method>

This code works fine and no exception shown in logs as well. But also no logs are getting printed which I have added to check if method is getting called or not. It seems with this approach method is not getting called.

When I do little bit changes as method name="initialize" as below
2. <method name="initialize"><![CDATA[favoritesClass = new Packages.SampleRowUpdater();
favorites = favoritesClass.readData(dataSetRow["LASTUPDATEDUSER"]);
totalrows = favorites.size();
currentrow = 0;]]></method>

I am getting below exception.
TypeError: [JavaPackage SampleRowUpdater] is not a function, it is object. (/report/method[@name="initialize"]#1)
at org.eclipse.birt.report.engine.javascript.JavascriptEngine.evaluate(JavascriptEngine.java:295)
at org.eclipse.birt.core.script.ScriptContext.evaluate(ScriptContext.java:159)
at org.eclipse.birt.report.engine.executor.ExecutionContext.evaluate(ExecutionContext.java:789)
at org.eclipse.birt.report.engine.executor.ExecutionContext.evaluate(ExecutionContext.java:718)
at org.eclipse.birt.report.engine.script.internal.ScriptExecutor.handleScriptInternal(ScriptExecutor.java:118)
at org.eclipse.birt.report.engine.script.internal.ScriptExecutor.handleScript(ScriptExecutor.java:105)
at org.eclipse.birt.report.engine.script.internal.ReportScriptExecutor.handleInitialize(ReportScriptExecutor.java:84)
... 77 more
Caused by: org.mozilla.javascript.EcmaError: TypeError: [JavaPackage SampleRowUpdater] is not a function, it is object.

I am not sure if this is the right method or we can use handler as well. I tried following some examples of Handler creation but I didn't get how to use the handler in Birt again. I am new to Birt. I am not aware which is the best way to use java class in birt report and how to use java class method in Birt report.
I request for help.
Previous Topic:BIRT report data mismatch
Next Topic:I built BIRT against Eclipse 2020-06
Goto Forum:
  


Current Time: Tue Sep 21 08:29:51 GMT 2021

Powered by FUDForum. Page generated in 0.01688 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top