Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » BIRT » Scripted datasource : wrong scope for "this" in Birt 4.2.1(The scope of the variable this has changed in 4.2.1)
Scripted datasource : wrong scope for "this" in Birt 4.2.1 [message #1014347] Mon, 25 February 2013 16:29 Go to next message
RWIL Mising name is currently offline RWIL Mising name
Messages: 28
Registered: February 2011
Junior Member
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 &lt;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 16:34]

Report message to a moderator

Re: Scripted datasource : wrong scope for "this" in Birt 4.2.1 [message #1014386 is a reply to message #1014347] Mon, 25 February 2013 17:56 Go to previous messageGo to next message
Michael Williams is currently offline Michael Williams
Messages: 1595
Registered: July 2009
Senior Member

All I've done is run the report in a few outputs, so far. I haven't looked at the script. It seems that the only output that has the issue you're seeing is the web viewer output. The others show your expected output. So, something is not working right when using separate run and render tasks. Let me look at it a little closer and I'll post back again.

Michael

Add interactivity, scheduling, sharing, live Excel export, and JS integration to your BIRT app with the new, free BIRT server, BIRT iHub F-Type.
Re: Scripted datasource : wrong scope for "this" in Birt 4.2.1 [message #1014399 is a reply to message #1014386] Mon, 25 February 2013 18:45 Go to previous messageGo to next message
Michael Williams is currently offline Michael Williams
Messages: 1595
Registered: July 2009
Senior Member

Even if I remove the "this." portion, the same happens with the web viewer output. If the second table is removed from the first, they both count to the values they should, there is no sharing of variables. If the names are changed to not be the same, there is not an issue. You might try downloading the latest build of BIRT 4.2.2 and seeing if it has the same issue. If it does, please log a bug and post the bug info in here.

Michael

Add interactivity, scheduling, sharing, live Excel export, and JS integration to your BIRT app with the new, free BIRT server, BIRT iHub F-Type.
Re: Scripted datasource : wrong scope for "this" in Birt 4.2.1 [message #1014691 is a reply to message #1014399] Tue, 26 February 2013 09:39 Go to previous messageGo to next message
RWIL Mising name is currently offline RWIL Mising name
Messages: 28
Registered: February 2011
Junior Member
Thanks Michael.

I'm downloading the birt runtime 4.2.2RC3 build, and I will do the test.

Kind regards
Re: Scripted datasource : wrong scope for "this" in Birt 4.2.1 [message #1014704 is a reply to message #1014691] Tue, 26 February 2013 10:15 Go to previous messageGo to next message
RWIL Mising name is currently offline RWIL Mising name
Messages: 28
Registered: February 2011
Junior Member
I've made the test, but unfortunatly the problem remains in 4.2.2RC3.

I've created a bug report for this issue : https://bugs.eclipse.org/bugs/show_bug.cgi?id=401770

We will rollback to version 2.6.2 until this problem will be fixed.

Thanks for your effort & king regards

Renaud
Re: Scripted datasource : wrong scope for "this" in Birt 4.2.1 [message #1014854 is a reply to message #1014704] Tue, 26 February 2013 15:42 Go to previous message
Michael Williams is currently offline Michael Williams
Messages: 1595
Registered: July 2009
Senior Member

Sounds good. Thanks for the update!

Michael

Add interactivity, scheduling, sharing, live Excel export, and JS integration to your BIRT app with the new, free BIRT server, BIRT iHub F-Type.
Previous Topic:Evaluate all datasets for nulls
Next Topic:How to give each table in the report a name
Goto Forum:
  


Current Time: Wed Sep 17 17:51:30 GMT 2014

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

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