Bug 326885 - Using resource scripts in chart cause ReferenceError
Summary: Using resource scripts in chart cause ReferenceError
Status: NEW
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: BIRT (show other bugs)
Version: 2.6.1   Edit
Hardware: PC Windows XP
: P3 normal with 2 votes (vote)
Target Milestone: ---   Edit
Assignee: Birt-Chart-inbox@eclipse.org CLA
QA Contact: Xiaoying Gu CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-10-04 02:36 EDT by Missing name CLA
Modified: 2010-11-19 03:53 EST (History)
2 users (show)

See Also:


Attachments
Report example causing chart reference error (75.92 KB, application/octet-stream)
2010-11-19 03:51 EST, Missing name CLA
no flags Details
Script file (330 bytes, application/x-javascript)
2010-11-19 03:52 EST, Missing name CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Missing name CLA 2010-10-04 02:36:14 EDT
Resource scripts assigned to report via Report - Resources - Javascript files cannot be directly used in chart scripts. Calling any of the the resource scripts generates ReferenceError when report is previewed.
Comment 1 Julien CLA 2010-11-05 05:22:51 EDT
This issue is happening also in the following context:

a) Define an external file as javascript resource in a library (rptlibrary).

b) You will see that you can use the functions defined in your external file everywhere in the library (report items, master pages, etc).

c) Now create a report design file (rtpdesign) and include you rptlibrary in that new report.

d) Using one of the functions defined in the external javascript file from the initialize() scripting method of the report causes a reference error. The functions from the external javascript file are not seen.

Nov 5, 2010 10:09:17 AM org.eclipse.birt.report.engine.script.internal.ScriptExecutor addException
WARNING: There are errors evaluating script "reportContext.getDesignHandle().title = params["par_title"].value +
        " - " + formatMonth(params["par_month"].value);
":
ReferenceError: "formatMonth" is not defined. (/report/method[@name="initialize"]#2)
Comment 2 Julien CLA 2010-11-05 06:32:19 EDT
I forgot to mention something important !

The ReferenceError is emitted BUT the PDF file outputted, once ran and rendered, has the correct data. In my case, formatMonth as returned a value and that value is correctly displayed in my PDF.


ReferenceError: "formatMonth" is not defined. (/report/method[@name="initialize"]#1)
	at org.eclipse.birt.report.engine.javascript.JavascriptEngine.evaluate(JavascriptEngine.java:287)
	at org.eclipse.birt.core.script.ScriptContext.evaluate(ScriptContext.java:154)
	at org.eclipse.birt.report.engine.executor.ExecutionContext.evaluate(ExecutionContext.java:743)
	at org.eclipse.birt.report.engine.executor.ExecutionContext.evaluate(ExecutionContext.java:672)
	at org.eclipse.birt.report.engine.script.internal.ScriptExecutor.handleScriptInternal(ScriptExecutor.java:61)
	at org.eclipse.birt.report.engine.script.internal.ScriptExecutor.handleScript(ScriptExecutor.java:48)
	at org.eclipse.birt.report.engine.script.internal.ReportScriptExecutor.handleInitialize(ReportScriptExecutor.java:44)
	... 12 more
Caused by: org.mozilla.javascript.EcmaError: ReferenceError: "formatMonth" is not defined. (/report/method[@name="initialize"]#1)
	at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3654)
	at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3632)
	at org.mozilla.javascript.ScriptRuntime.notFoundError(ScriptRuntime.java:3717)
	at org.mozilla.javascript.ScriptRuntime.nameOrFunction(ScriptRuntime.java:1758)
	at org.mozilla.javascript.ScriptRuntime.getNameFunctionAndThis(ScriptRuntime.java:2135)
	at org.mozilla.javascript.optimizer.OptRuntime.callName(OptRuntime.java:95)
	at org.mozilla.javascript.gen.c142._c0(/report/method[@name="initialize"]:1)
	at org.mozilla.javascript.gen.c142.call(/report/method[@name="initialize"])
	at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:398)
	at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3065)
	at org.mozilla.javascript.gen.c142.call(/report/method[@name="initialize"])
	at org.mozilla.javascript.gen.c142.exec(/report/method[@name="initialize"])
	at org.eclipse.birt.report.engine.javascript.JavascriptEngine.evaluate(JavascriptEngine.java:282)
	... 18 more

Julien
Comment 3 Xiaoying Gu CLA 2010-11-15 01:18:05 EST
(In reply to comment #0)
> Resource scripts assigned to report via Report - Resources - Javascript files
> cannot be directly used in chart scripts. Calling any of the the resource
> scripts generates ReferenceError when report is previewed.

kalle,

Could you give an example how you used resource scripts in Chart scripting?
Comment 4 Xiaoying Gu CLA 2010-11-16 03:35:35 EST
(In reply to comment #2)
> I forgot to mention something important !
> 
> The ReferenceError is emitted BUT the PDF file outputted, once ran and
> rendered, has the correct data. In my case, formatMonth as returned a value and
> that value is correctly displayed in my PDF.
> 
> 
> ReferenceError: "formatMonth" is not defined.
> (/report/method[@name="initialize"]#1)
>     at
> org.eclipse.birt.report.engine.javascript.JavascriptEngine.evaluate(JavascriptEngine.java:287)
>     at
> org.eclipse.birt.core.script.ScriptContext.evaluate(ScriptContext.java:154)
>     at
> org.eclipse.birt.report.engine.executor.ExecutionContext.evaluate(ExecutionContext.java:743)
>     at
> org.eclipse.birt.report.engine.executor.ExecutionContext.evaluate(ExecutionContext.java:672)
>     at
> org.eclipse.birt.report.engine.script.internal.ScriptExecutor.handleScriptInternal(ScriptExecutor.java:61)
>     at
> org.eclipse.birt.report.engine.script.internal.ScriptExecutor.handleScript(ScriptExecutor.java:48)
>     at
> org.eclipse.birt.report.engine.script.internal.ReportScriptExecutor.handleInitialize(ReportScriptExecutor.java:44)
>     ... 12 more
> Caused by: org.mozilla.javascript.EcmaError: ReferenceError: "formatMonth" is
> not defined. (/report/method[@name="initialize"]#1)
>     at
> org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3654)
>     at
> org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3632)
>     at
> org.mozilla.javascript.ScriptRuntime.notFoundError(ScriptRuntime.java:3717)
>     at
> org.mozilla.javascript.ScriptRuntime.nameOrFunction(ScriptRuntime.java:1758)
>     at
> org.mozilla.javascript.ScriptRuntime.getNameFunctionAndThis(ScriptRuntime.java:2135)
>     at org.mozilla.javascript.optimizer.OptRuntime.callName(OptRuntime.java:95)
>     at
> org.mozilla.javascript.gen.c142._c0(/report/method[@name="initialize"]:1)
>     at org.mozilla.javascript.gen.c142.call(/report/method[@name="initialize"])
>     at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:398)
>     at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3065)
>     at org.mozilla.javascript.gen.c142.call(/report/method[@name="initialize"])
>     at org.mozilla.javascript.gen.c142.exec(/report/method[@name="initialize"])
>     at
> org.eclipse.birt.report.engine.javascript.JavascriptEngine.evaluate(JavascriptEngine.java:282)
>     ... 18 more
> 
> Julien

Julien,

Could you also attache your report design and js file here? We can not reproduce this issue in our environment.
Comment 5 Missing name CLA 2010-11-19 03:51:40 EST
Created attachment 183450 [details]
Report example causing chart reference error

This report has an example about chart script error.

Report contains two charts that are both setting own width in function afterDataSetFilled and use external script when doing so. Reference error is generated when script is used directly. Other chart uses script via getScriptable() and is just to indicate that script is valid.
Comment 6 Missing name CLA 2010-11-19 03:52:20 EST
Created attachment 183451 [details]
Script file

This file contains script used in example report.
Comment 7 Missing name CLA 2010-11-19 03:53:22 EST
Example report and script file are added.

(In reply to comment #3)
> (In reply to comment #0)
> > Resource scripts assigned to report via Report - Resources - Javascript files
> > cannot be directly used in chart scripts. Calling any of the the resource
> > scripts generates ReferenceError when report is previewed.
> 
> kalle,
> 
> Could you give an example how you used resource scripts in Chart scripting?