Я сталкиваюсь с этой ошибкой при попытке создать отчет BIRT
на основе источника данных по сценарию:
Caused by: org.mozilla.javascript.EcmaError: ReferenceError: "count" n'est pas défini (/report/data-sets/script-data-set[@id="248"]/method[@name="fetch"]#1)
На английском языке: неопределенная переменная "count"
Я не нашел достаточной документации по этому делу.
Это классы Java и модель отчета.
Спасибо за помощь.
AppDS (класс источника данных):
package projds;
import java.util.ArrayList;
import java.util.List;
public class AppDS {
public List<Entity> getEntities() {
List<Entity> t = new ArrayList<Entity>();
t.add(new Entity("A1"));
t.add(new Entity("A2"));
t.add(new Entity("A3"));
t.add(new Entity("A4"));
return t;
}
}
Класс сущности:
package projds;
public class Entity {
String name;
public Entity() {
super();
}
public Entity(String name) {
super();
this.name = name;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
Модель отчета:
<?xml version="1.0" encoding="UTF-8"?>
<report xmlns="http://www.eclipse.org/birt/2005/design" version="3.2.23" id="1">
<property name="createdBy">Eclipse BIRT Designer Version 4.6.0.v201606072122</property>
<property name="units">in</property>
<property name="iconFile">/templates/first_report.gif</property>
<property name="bidiLayoutOrientation">ltr</property>
<property name="imageDPI">96</property>
<data-sources>
<script-data-source name="dsrc1" id="247"/>
</data-sources>
<data-sets>
<script-data-set name="dset1" id="248">
<list-property name="resultSetHints">
<structure>
<property name="position">0</property>
<property name="name">colName</property>
<property name="dataType">string</property>
</structure>
</list-property>
<list-property name="columnHints">
<structure>
<property name="columnName">colName</property>
<text-property name="displayName">The Name</text-property>
</structure>
</list-property>
<structure name="cachedMetaData">
<list-property name="resultSet">
<structure>
<property name="position">1</property>
<property name="name">colName</property>
<property name="dataType">string</property>
</structure>
</list-property>
</structure>
<property name="dataSource">dsrc1</property>
<method name="open"><![CDATA[importPackage(Packages.projds);
var dummyObject = new Object();
var gsh = new AppDS();
var data = gsh.getEntities();
var count = 0;]]></method>
<method name="fetch"><![CDATA[if(count < data.size()) {
row["colName"] = data.get(count).getName();
count++;
return true;
}
return false;]]></method>
<method name="close"><![CDATA[dummyObject = null;
gsh = null;
data = null;
var count = 0;]]></method>
</script-data-set>
</data-sets>
<styles>
<style name="report" id="110">
<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>
<label id="245">
<property name="fontFamily">sans-serif</property>
<property name="fontSize">x-large</property>
<property name="fontWeight">bold</property>
<property name="textAlign">center</property>
<text-property name="text">Customer Listing</text-property>
</label>
<table id="325">
<property name="dataSet">dset1</property>
<list-property name="boundDataColumns">
<structure>
<property name="name">colName</property>
<text-property name="displayName">The Name</text-property>
<expression name="expression" type="javascript">dataSetRow["colName"]</expression>
<property name="dataType">string</property>
</structure>
</list-property>
<column id="334"/>
<header>
<row id="326">
<cell id="327">
<label id="328">
<text-property name="text">The Name</text-property>
</label>
</cell>
</row>
</header>
<detail>
<row id="329">
<cell id="330">
<data id="331">
<property name="resultSetColumn">colName</property>
</data>
</cell>
</row>
</detail>
<footer>
<row id="332">
<cell id="333"/>
</row>
</footer>
</table>
</body>
<property name="pageVariables">
<variable-element name="data">
<property name="type">report</property>
</variable-element>
</property>
</report>