Scripted datasource : wrong scope for "this" in Birt 4.2.1 [message #1014347] |
Mon, 25 February 2013 11:29  |
Eclipse User |
|
|
|
Hi,
Our BIRT reports are using scripted datasources. Most of them were written in Birt 2.6.2 and were running without problem.
But we have tried to migrate to Birt 4.2.1 and it seems that the scope of the script variable "this" has changed.
In the previous version, each dataset has its own "this" and there were no confusion between the "this" object of the main dataset and the "this" object of a sub dataset.
But in 4.2.1, both datasets seems to share the same object "this" and -of course- it's a problem.
Here is a sample report to show the issue.
In Birt 2.6.2, the report shows :
1
1
2
3
4
5
2
1
2
3
4
5
3
1
2
... (you got the idea...)
But in Birt 4.2.1 it only shows this :
1
1
2
3
4
5
/end of report !
The report source code :
<?xml version="1.0" encoding="UTF-8"?>
<report xmlns="http://www.eclipse.org/birt/2005/design" version="3.2.22" id="1">
<property name="createdBy">Eclipse BIRT Designer Version 2.6.2.r262_v20110209 Build <2.6.2.v20110214-1523></property>
<property name="units">in</property>
<property name="iconFile">/templates/blank_report.gif</property>
<property name="bidiLayoutOrientation">ltr</property>
<property name="imageDPI">96</property>
<data-sources>
<script-data-source name="myDataSource" id="7"/>
</data-sources>
<data-sets>
<script-data-set name="myDataSet1" id="8">
<list-property name="resultSetHints">
<structure>
<property name="position">1</property>
<property name="name">myColumnDS1</property>
<property name="dataType">string</property>
</structure>
</list-property>
<list-property name="columnHints">
<structure>
<property name="columnName">myColumnDS1</property>
</structure>
</list-property>
<structure name="cachedMetaData">
<list-property name="resultSet">
<structure>
<property name="position">1</property>
<property name="name">myColumnDS1</property>
<property name="dataType">string</property>
</structure>
</list-property>
</structure>
<method name="beforeOpen"><![CDATA[this.index = 0;
this.maxValue = 10;
]]></method>
<property name="dataSource">myDataSource</property>
<method name="fetch"><![CDATA[if (this.index >= this.maxValue) {
return false;
}
this.index++;
row["myColumnDS1"] = this.index;
return true;]]></method>
</script-data-set>
<script-data-set name="myDataSet2" id="9">
<list-property name="resultSetHints">
<structure>
<property name="position">1</property>
<property name="name">myColumnDS2</property>
<property name="dataType">string</property>
</structure>
</list-property>
<list-property name="columnHints">
<structure>
<property name="columnName">myColumnDS2</property>
</structure>
</list-property>
<structure name="cachedMetaData">
<list-property name="resultSet">
<structure>
<property name="position">1</property>
<property name="name">myColumnDS2</property>
<property name="dataType">string</property>
</structure>
</list-property>
</structure>
<method name="beforeOpen"><![CDATA[this.index = 0;
this.maxValue = 5;
]]></method>
<property name="dataSource">myDataSource</property>
<method name="fetch"><![CDATA[if (this.index >= this.maxValue) {
return false;
}
this.index++;
row["myColumnDS2"] = this.index;
return true;]]></method>
</script-data-set>
</data-sets>
<styles>
<style name="report" id="4">
<property name="fontFamily">sans-serif</property>
<property name="fontSize">10pt</property>
</style>
</styles>
<page-setup>
<simple-master-page name="Simple MasterPage" id="2">
<page-footer>
<text id="3">
<property name="contentType">html</property>
<text-property name="content"><![CDATA[<value-of>new Date()</value-of>]]></text-property>
</text>
</page-footer>
</simple-master-page>
</page-setup>
<body>
<table id="10">
<property name="dataSet">myDataSet1</property>
<list-property name="boundDataColumns">
<structure>
<property name="name">myColumnDS1</property>
<text-property name="displayName">myColumnDS1</text-property>
<expression name="expression" type="javascript">dataSetRow["myColumnDS1"]</expression>
<property name="dataType">string</property>
</structure>
</list-property>
<property name="sortByGroups">false</property>
<column id="17"/>
<detail>
<row id="13">
<cell id="14">
<data id="18">
<property name="resultSetColumn">myColumnDS1</property>
</data>
</cell>
</row>
<row id="19">
<cell id="20">
<property name="paddingLeft">20pt</property>
<table id="21">
<property name="dataSet">myDataSet2</property>
<list-property name="boundDataColumns">
<structure>
<property name="name">myColumnDS2</property>
<text-property name="displayName">myColumnDS2</text-property>
<expression name="expression" type="javascript">dataSetRow["myColumnDS2"]</expression>
<property name="dataType">string</property>
</structure>
</list-property>
<column id="28"/>
<detail>
<row id="24">
<cell id="25">
<data id="29">
<property name="resultSetColumn">myColumnDS2</property>
</data>
</cell>
</row>
</detail>
</table>
</cell>
</row>
</detail>
</table>
</body>
</report>
Is this a bug ? Is a it a known bug or a new one ?
Kind regards
Renaud Willems
[Updated on: Mon, 25 February 2013 11:34] by Moderator
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.07452 seconds