Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » Iterating the ArrayList within another ArrayList
Iterating the ArrayList within another ArrayList [message #368577] Thu, 11 June 2009 07:33 Go to next message
Roopa  is currently offline Roopa Friend
Messages: 20
Registered: July 2009
Junior Member
Hi,
I am working on Birt 2.3.2.

I have an issue of iterating an Arraylist within another Arraylists.
Is there any way in Birt that can solve this problem.

Here is my scenario. For instance, I have an Arraylist of employees .And
within each employee ,I have a list of different kind of graphs to be
shown on the report. Currently, what I have to do is, for each graph in
the inner list, I will have to pass the employee information separately
every time . Is there any way that , I just pass an employee info first ,
and along with that send a list of graphs' list ,so that I can process all
the graphs and then move on to next employee.

Currently, in the Birtscript ,as per I know, we cannot iterate an array
list within another. Please correct me ,if I am wrong.

Can you help me with an alternative solution for this.

Thanks.
Re: Iterating the ArrayList within another ArrayList [message #368587 is a reply to message #368577] Thu, 11 June 2009 21:35 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: jasonweathersby.windstream.net

Roopa,

You should be able iterate list within list in script in BIRT.
Take a look at how you could do this using inputParam for the inner dataset.

Jason

<?xml version="1.0" encoding="UTF-8"?>
<report xmlns="http://www.eclipse.org/birt/2005/design" version="3.2.17"
id="1">
<property name="createdBy">Eclipse BIRT Designer Version
2.3.2.r232_20090202 Build &lt;2.3.2.v20090218-0730></property>
<property name="units">in</property>
<property name="comments">Copyright (c) 2006 &lt;&lt;Your Company
Name here>></property>
<method name="initialize"><![CDATA[importPackage( Packages.java.util );
importPackage( Packages.java.lang );

var outerMap = new Hashtable();
var innerMap = new Hashtable();

for ( i=0; i<50; i++ ){
var mystring = "Outerrow_" + i;
var myinnerstring = "Innerrow_" + i;
outerMap.put(i, mystring);
innerMap.put( mystring, myinnerstring );
}
reportContext.setPersistentGlobalVariable("outerMap", outerMap);
reportContext.setPersistentGlobalVariable("innerMap", innerMap);]]></method>
<data-sources>
<script-data-source name="Data Source" id="4"/>
</data-sources>
<data-sets>
<script-data-set name="outer" id="5">
<list-property name="resultSetHints">
<structure>
<property name="position">0</property>
<property name="name">outtercol</property>
<property name="dataType">string</property>
</structure>
</list-property>
<list-property name="columnHints">
<structure>
<property name="columnName">outtercol</property>
</structure>
</list-property>
<structure name="cachedMetaData">
<list-property name="resultSet">
<structure>
<property name="position">1</property>
<property name="name">outtercol</property>
<property name="dataType">string</property>
</structure>
</list-property>
</structure>
<property name="dataSource">Data Source</property>
<method name="open"><![CDATA[hMap =
reportContext.getPersistentGlobalVariable("outerMap");
iter = hMap.entrySet().iterator();]]></method>
<method name="fetch"><![CDATA[if( iter.hasNext() ){
myObject = iter.next();
row["outtercol"] = myObject.getValue().toString();
return true;

}else{

return false;

}]]></method>
</script-data-set>
<script-data-set name="inner" id="6">
<list-property name="resultSetHints">
<structure>
<property name="position">0</property>
<property name="name">innercol</property>
<property name="dataType">string</property>
</structure>
</list-property>
<list-property name="columnHints">
<structure>
<property name="columnName">innercol</property>
</structure>
</list-property>
<structure name="cachedMetaData">
<list-property name="resultSet">
<structure>
<property name="position">1</property>
<property name="name">innercol</property>
<property name="dataType">string</property>
</structure>
</list-property>
</structure>
<property name="dataSource">Data Source</property>
<list-property name="parameters">
<structure>
<property name="name">innerparm</property>
<property name="dataType">string</property>
<property name="position">1</property>
<expression name="defaultValue">testkey</expression>
<property name="isInput">true</property>
<property name="isOutput">true</property>
</structure>
</list-property>
<method name="open"><![CDATA[i = 0;
jj = inputParams["innerparm"];]]></method>
<method name="fetch"><![CDATA[iMap =
reportContext.getPersistentGlobalVariable("innerMap");
inObj = iMap.get(jj);
if( i > 0 )return false;

if( inObj != null ){
row["innercol"] = inObj.toString();

}
i++
return true;]]></method>
</script-data-set>
</data-sets>
<styles>
<style name="detail" id="54">
<property name="backgroundColor">#BACAE2</property>
<property name="fontFamily">"Arial"</property>
<property name="fontSize">small</property>
<property name="paddingTop">0px</property>
<property name="paddingLeft">0px</property>
<property name="paddingBottom">0px</property>
<property name="paddingRight">0px</property>
</style>
<style name="headerfooter" id="55">
<property name="backgroundColor">#004080</property>
<property name="fontFamily">"Arial"</property>
<property name="fontSize">small</property>
<property name="fontWeight">bold</property>
<property name="color">#FFFFFF</property>
</style>
<style name="groupheader" id="56">
<property name="backgroundColor">#0080FF</property>
<property name="fontFamily">"Arial"</property>
<property name="fontSize">small</property>
<property name="fontWeight">bold</property>
<property name="color">#FFFFFF</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="7">
<property name="width">100%</property>
<property name="dataSet">outer</property>
<list-property name="boundDataColumns">
<structure>
<property name="name">outtercol</property>
<expression
name="expression">dataSetRow["outtercol"]</expression>
<property name="dataType">string</property>
</structure>
</list-property>
<property name="pageBreakInterval">50</property>
<column id="16"/>
<column id="20"/>
<header>
<row id="8">
<property name="style">headerfooter</property>
<cell id="9">
<label id="10">
<text-property
name="text">OuterDSCol</text-property>
</label>
</cell>
<cell id="17"/>
</row>
</header>
<detail>
<row id="11">
<property name="style">detail</property>
<cell id="12">
<data id="13">
<property
name="resultSetColumn">outtercol</property>
</data>
</cell>
<cell id="18">
<table id="21">
<property name="width">100%</property>
<property name="dataSet">inner</property>
<list-property name="paramBindings">
<structure>
<property
name="paramName">innerparm</property>
<expression
name="expression">row["outtercol"]</expression>
</structure>
</list-property>
<list-property name="boundDataColumns">
<structure>
<property
name="name">innercol</property>
<expression
name="expression">dataSetRow["innercol"]</expression>
<property
name="dataType">string</property>
</structure>
</list-property>
<property
name="pageBreakInterval">50</property>
<column id="30"/>
<header>
<row id="22">
<cell id="23">
<label id="24">
<text-property
name="text">InnerDataSetCol</text-property>
</label>
</cell>
</row>
</header>
<detail>
<row id="25">
<property
name="style">groupheader</property>
<cell id="26">
<data id="27">
<property
name="resultSetColumn">innercol</property>
</data>
</cell>
</row>
</detail>
</table>
</cell>
</row>
</detail>
<footer>
<row id="14">
<property name="style">headerfooter</property>
<cell id="15"/>
<cell id="19"/>
</row>
</footer>
</table>
</body>
</report>

Roopa wrote:
> Hi,
> I am working on Birt 2.3.2.
>
> I have an issue of iterating an Arraylist within another Arraylists.
> Is there any way in Birt that can solve this problem.
>
> Here is my scenario. For instance, I have an Arraylist of employees
> .And within each employee ,I have a list of different kind of graphs to
> be shown on the report. Currently, what I have to do is, for each graph
> in the inner list, I will have to pass the employee information
> separately every time . Is there any way that , I just pass an employee
> info first , and along with that send a list of graphs' list ,so that I
> can process all the graphs and then move on to next employee.
>
> Currently, in the Birtscript ,as per I know, we cannot iterate an array
> list within another. Please correct me ,if I am wrong.
>
> Can you help me with an alternative solution for this.
>
> Thanks.
>
>
Re: Iterating the ArrayList within another ArrayList [message #368619 is a reply to message #368587] Tue, 16 June 2009 10:03 Go to previous messageGo to next message
Roopa  is currently offline Roopa Friend
Messages: 20
Registered: July 2009
Junior Member
Thanks Jason. will try with this.
Re: Iterating the ArrayList within another ArrayList [message #368758 is a reply to message #368619] Wed, 24 June 2009 14:25 Go to previous messageGo to next message
Roopa  is currently offline Roopa Friend
Messages: 20
Registered: July 2009
Junior Member
Hi Jason,

I tried the same example with the two data sets. Here am having two
arraylists which I am passing from the Java code. But i am really not able
to understand, how do i link the two arraylists in the script.
Am attaching the Javacode and xml of the code sample. Please advice ,how
do i go forward with this problem.

Xml file--->

***********************************************************
<?xml version="1.0" encoding="UTF-8"?>
<report xmlns="http://www.eclipse.org/birt/2005/design" version="3.2.17"
id="1">
<property name="createdBy">Eclipse BIRT Designer Version
2.3.2.r232_20081120 Build &lt;2.3.2.v20081128-0730></property>
<property name="units">in</property>
<method name="initialize"><![CDATA[importPackage( Packages.java.util );
importPackage( Packages.java.lang );

var outerMap = new Hashtable();
var innerMap = new Hashtable();

for ( i=0; i<50; i++ ){
var mystring = "Outerrow_" + i;
var myinnerstring = "Innerrow_" + i;
outerMap.put(i, mystring);
innerMap.put( mystring, myinnerstring );
}
reportContext.setPersistentGlobalVariable("outerMap", outerMap);
reportContext.setPersistentGlobalVariable("innerMap",
innerMap);]]></method>
<property name="iconFile">/templates/blank_report.gif</property>
<property name="bidiLayoutOrientation">ltr</property>
<data-sources>
<script-data-source name="EmpDS" id="24"/>
</data-sources>
<data-sets>
<script-data-set name="EmpDS" id="25">
<list-property name="resultSetHints">
<structure>
<property name="position">0</property>
<property name="name">EmpID</property>
<property name="dataType">string</property>
</structure>
<structure>
<property name="position">1</property>
<property name="name">EmpName</property>
<property name="dataType">string</property>
</structure>
</list-property>
<list-property name="columnHints">
<structure>
<property name="columnName">EmpID</property>
</structure>
<structure>
<property name="columnName">EmpName</property>
</structure>
</list-property>
<structure name="cachedMetaData">
<list-property name="resultSet">
<structure>
<property name="position">1</property>
<property name="name">EmpID</property>
<property name="dataType">string</property>
</structure>
<structure>
<property name="position">2</property>
<property name="name">EmpName</property>
<property name="dataType">string</property>
</structure>
</list-property>
</structure>
<property name="dataSource">EmpDS</property>
<method name="open"><![CDATA[hMap =
reportContext.getPersistentGlobalVariable("outerMap");
iter = hMap.entrySet().iterator();]]></method>
<method name="fetch"><![CDATA[if( iter.hasNext() ){
myObject = iter.next();
row["EmpName"] = myObject.getValue().toString();
return true;

}else{

return false;

}]]></method>
</script-data-set>
<script-data-set name="EmpDetailsDS" id="26">
<list-property name="resultSetHints">
<structure>
<property name="position">0</property>
<property name="name">empComp</property>
<property name="dataType">string</property>
</structure>
<structure>
<property name="position">1</property>
<property name="name">empyrs</property>
<property name="dataType">string</property>
</structure>
</list-property>
<list-property name="columnHints">
<structure>
<property name="columnName">empComp</property>
</structure>
<structure>
<property name="columnName">empyrs</property>
</structure>
</list-property>
<structure name="cachedMetaData">
<list-property name="resultSet">
<structure>
<property name="position">1</property>
<property name="name">empComp</property>
<property name="dataType">string</property>
</structure>
<structure>
<property name="position">2</property>
<property name="name">empyrs</property>
<property name="dataType">string</property>
</structure>
</list-property>
</structure>
<property name="dataSource">EmpDS</property>
<method name="open"><![CDATA[i = 0;
jj = inputParams["innerparm"];]]></method>
<method name="fetch"><![CDATA[iMap =
reportContext.getPersistentGlobalVariable("innerMap");
inObj = iMap.get(jj);
if( i > 0 )return false;

if( inObj != null ){
row["empComp"] = inObj.getEmpComp();
row["empyrs"] = inObj.getEmpYrs();

}
i++
return true;]]></method>
</script-data-set>
</data-sets>
<styles>
<style name="report" id="4">
<property name="fontFamily">"Verdana"</property>
<property name="fontSize">10pt</property>
</style>
<style name="crosstab" id="5">
<property name="borderBottomColor">#CCCCCC</property>
<property name="borderBottomStyle">solid</property>
<property name="borderBottomWidth">1pt</property>
<property name="borderLeftColor">#CCCCCC</property>
<property name="borderLeftStyle">solid</property>
<property name="borderLeftWidth">1pt</property>
<property name="borderRightColor">#CCCCCC</property>
<property name="borderRightStyle">solid</property>
<property name="borderRightWidth">1pt</property>
<property name="borderTopColor">#CCCCCC</property>
<property name="borderTopStyle">solid</property>
<property name="borderTopWidth">1pt</property>
</style>
<style name="crosstab-cell" id="6">
<property name="borderBottomColor">#CCCCCC</property>
<property name="borderBottomStyle">solid</property>
<property name="borderBottomWidth">1pt</property>
<property name="borderLeftColor">#CCCCCC</property>
<property name="borderLeftStyle">solid</property>
<property name="borderLeftWidth">1pt</property>
<property name="borderRightColor">#CCCCCC</property>
<property name="borderRightStyle">solid</property>
<property name="borderRightWidth">1pt</property>
<property name="borderTopColor">#CCCCCC</property>
<property name="borderTopStyle">solid</property>
<property name="borderTopWidth">1pt</property>
</style>
</styles>
<page-setup>
<simple-master-page name="Simple MasterPage" id="2">
<property name="topMargin">0.25in</property>
<property name="leftMargin">0.25in</property>
<property name="bottomMargin">0.25in</property>
<property name="rightMargin">0.25in</property>
<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="103">
<property name="width">100%</property>
<property name="dataSet">EmpDS</property>
<list-property name="boundDataColumns">
<structure>
<property name="name">EmpID</property>
<expression
name="expression">dataSetRow["EmpID"]</expression>
<property name="dataType">string</property>
</structure>
<structure>
<property name="name">EmpName</property>
<expression
name="expression">dataSetRow["EmpName"]</expression>
<property name="dataType">string</property>
</structure>
</list-property>
<column id="110"/>
<detail>
<row id="106">
<cell id="107">
<data id="111">
<property
name="resultSetColumn">EmpName</property>
</data>
</cell>
</row>
</detail>
</table>
<table id="112">
<property name="width">100%</property>
<property name="dataSet">EmpDetailsDS</property>
<list-property name="boundDataColumns">
<structure>
<property name="name">empComp</property>
<expression
name="expression">dataSetRow["empComp"]</expression>
<property name="dataType">string</property>
</structure>
<structure>
<property name="name">empyrs</property>
<expression
name="expression">dataSetRow["empyrs"]</expression>
<property name="dataType">string</property>
</structure>
</list-property>
<column id="122"/>
<column id="123"/>
<header>
<row id="113">
<cell id="114">
<label id="125">
<text-property
name="text">empComp</text-property>
</label>
</cell>
<cell id="115">
<label id="127">
<text-property
name="text">empyrs</text-property>
</label>
</cell>
</row>
</header>
<detail>
<row id="116">
<cell id="117">
<data id="126">
<property
name="resultSetColumn">empComp</property>
</data>
</cell>
<cell id="118">
<data id="128">
<property
name="resultSetColumn">empyrs</property>
</data>
</cell>
</row>
</detail>
<footer>
<row id="119">
<cell id="120"/>
<cell id="121"/>
</row>
</footer>
</table>
</body>
</report>

************************************************************ ***************
my source file --- empRep.Java
(A simple file creating two arraylists)


import java.util.ArrayList;
import java.util.HashMap;



public class empRep {

private String empName ="";
private String empComp = "";
private String empYrs = "";
ArrayList empList=new ArrayList();
ArrayList empDetList =new ArrayList();

public String getEmpName() {
return empName;
}

public String getEmpComp() {
return empComp;
}

public String getEmpYrs() {
return empYrs;
}

public void setEmpName(String empName) {
this.empName =empName ;
}

public void setEmpComp(String empComp) {
this.empComp =empComp ;
}

public void setEmpYrs(String empYrs) {
this.empYrs =empYrs ;
}

public ArrayList getEmpList() {
return empList;
}

public ArrayList getEmpDetList() {
return empDetList;
}

public void generateData() {
empRep empRepObj=new empRep();
empRep empRepObj1 = new empRep();
for(int i=1;i<4;i++) {
empRepObj1 = new empRep();
empRepObj1.setEmpName("Emp"+i);
empList.add(empRepObj1);
for(int k=0;k<3;k++) {
empRepObj = new empRep();
empRepObj.setEmpComp("EmpComp"+ i+k);
empRepObj.setEmpYrs("EmpYrs" +i+ k);
empDetList.add(empRepObj);
}

}
}


}

************************************************************ ***********
In the main()


empRep empRep1=new empRep();
empRep1.generateData();
List empList = empRep1.getEmpList();
List empDetailsList =empRep1.getEmpDetList();

IReportEngine engine = configureBirtEngine();
IReportRunnable design = null;

// Open the report design
design = engine.openReportDesign(RPTBASEPATH + ReportName
+ WebReport.RPTExtension);

IRunAndRenderTask runRenderTask = engine.createRunAndRenderTask(design);

RenderOption options = new RenderOption();
options.setOutputFileName(RPTOUTPUTDIR + ReportName + ".pdf");

// Set output format
options.setOutputFormat(".pdf");
runRenderTask.setRenderOption(options);

EngineConfig config = new EngineConfig();
HashMap hm = config.getAppContext();
hm.put("EmpDS", empList);
hm.put("EmpDetailsDS", empDetailsList);

runRenderTask.setAppContext(hm);
runAndRenderReport(runRenderTask, engine);


Thanks in Advance
Roopa
Re: Iterating the ArrayList within another ArrayList [message #368761 is a reply to message #368758] Wed, 24 June 2009 15:30 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: jasonweathersby.windstream.net

Roopa,

In that example you should nest the inner table into one of the columns
of the outer table and use binding tab to bind a dataset parameter for
the inner table to one of the row values from the outer table. So if
you want to do a employee list and employee details object it would be
structured like:

HashMap outer filled with employee objects, keyed on employee name
HashMap inner filled with employee detail objects keyed on employee name
or number.
//Note that the classes for these objects need to be in the cp of the
report engine
Then in the report you need to iterate over the outer hashmap for the
outer dataset and nest your inner table in the outer table column. The
key is to add an dataset input parameter to the inner dataset. This
parameter should be the key for the inner Map. Then in your open method
for the inner dataset you can get your emply details by calling
innermap.get(inputParams["myinputkey"]); If you use the binding tab and
bind the parameter to the outer tables row employeename field the engine
should automatically reset the input parameter for every row of data on
the outer table.

Jason


Roopa wrote:
> Hi Jason,
>
> I tried the same example with the two data sets. Here am having two
> arraylists which I am passing from the Java code. But i am really not
> able to understand, how do i link the two arraylists in the script.
> Am attaching the Javacode and xml of the code sample. Please advice ,how
> do i go forward with this problem.
>
> Xml file--->
>
> ***********************************************************
> <?xml version="1.0" encoding="UTF-8"?>
> <report xmlns="http://www.eclipse.org/birt/2005/design" version="3.2.17"
> id="1">
> <property name="createdBy">Eclipse BIRT Designer Version
> 2.3.2.r232_20081120 Build &lt;2.3.2.v20081128-0730></property>
> <property name="units">in</property>
> <method name="initialize"><![CDATA[importPackage( Packages.java.util );
> importPackage( Packages.java.lang );
>
> var outerMap = new Hashtable();
> var innerMap = new Hashtable();
>
> for ( i=0; i<50; i++ ){
> var mystring = "Outerrow_" + i;
> var myinnerstring = "Innerrow_" + i;
> outerMap.put(i, mystring);
> innerMap.put( mystring, myinnerstring );
> }
> reportContext.setPersistentGlobalVariable("outerMap", outerMap);
> reportContext.setPersistentGlobalVariable("innerMap",
> innerMap);]]></method>
> <property name="iconFile">/templates/blank_report.gif</property>
> <property name="bidiLayoutOrientation">ltr</property>
> <data-sources>
> <script-data-source name="EmpDS" id="24"/>
> </data-sources>
> <data-sets>
> <script-data-set name="EmpDS" id="25">
> <list-property name="resultSetHints">
> <structure>
> <property name="position">0</property>
> <property name="name">EmpID</property>
> <property name="dataType">string</property>
> </structure>
> <structure>
> <property name="position">1</property>
> <property name="name">EmpName</property>
> <property name="dataType">string</property>
> </structure>
> </list-property>
> <list-property name="columnHints">
> <structure>
> <property name="columnName">EmpID</property>
> </structure>
> <structure>
> <property name="columnName">EmpName</property>
> </structure>
> </list-property>
> <structure name="cachedMetaData">
> <list-property name="resultSet">
> <structure>
> <property name="position">1</property>
> <property name="name">EmpID</property>
> <property name="dataType">string</property>
> </structure>
> <structure>
> <property name="position">2</property>
> <property name="name">EmpName</property>
> <property name="dataType">string</property>
> </structure>
> </list-property>
> </structure>
> <property name="dataSource">EmpDS</property>
> <method name="open"><![CDATA[hMap =
> reportContext.getPersistentGlobalVariable("outerMap");
> iter = hMap.entrySet().iterator();]]></method>
> <method name="fetch"><![CDATA[if( iter.hasNext() ){
> myObject = iter.next();
> row["EmpName"] = myObject.getValue().toString();
> return true;
>
> }else{
>
> return false;
>
> }]]></method>
> </script-data-set>
> <script-data-set name="EmpDetailsDS" id="26">
> <list-property name="resultSetHints">
> <structure>
> <property name="position">0</property>
> <property name="name">empComp</property>
> <property name="dataType">string</property>
> </structure>
> <structure>
> <property name="position">1</property>
> <property name="name">empyrs</property>
> <property name="dataType">string</property>
> </structure>
> </list-property>
> <list-property name="columnHints">
> <structure>
> <property name="columnName">empComp</property>
> </structure>
> <structure>
> <property name="columnName">empyrs</property>
> </structure>
> </list-property>
> <structure name="cachedMetaData">
> <list-property name="resultSet">
> <structure>
> <property name="position">1</property>
> <property name="name">empComp</property>
> <property name="dataType">string</property>
> </structure>
> <structure>
> <property name="position">2</property>
> <property name="name">empyrs</property>
> <property name="dataType">string</property>
> </structure>
> </list-property>
> </structure>
> <property name="dataSource">EmpDS</property>
> <method name="open"><![CDATA[i = 0;
> jj = inputParams["innerparm"];]]></method>
> <method name="fetch"><![CDATA[iMap =
> reportContext.getPersistentGlobalVariable("innerMap");
> inObj = iMap.get(jj);
> if( i > 0 )return false;
>
> if( inObj != null ){
> row["empComp"] = inObj.getEmpComp();
> row["empyrs"] = inObj.getEmpYrs();
>
> }
> i++
> return true;]]></method>
> </script-data-set>
> </data-sets>
> <styles>
> <style name="report" id="4">
> <property name="fontFamily">"Verdana"</property>
> <property name="fontSize">10pt</property>
> </style>
> <style name="crosstab" id="5">
> <property name="borderBottomColor">#CCCCCC</property>
> <property name="borderBottomStyle">solid</property>
> <property name="borderBottomWidth">1pt</property>
> <property name="borderLeftColor">#CCCCCC</property>
> <property name="borderLeftStyle">solid</property>
> <property name="borderLeftWidth">1pt</property>
> <property name="borderRightColor">#CCCCCC</property>
> <property name="borderRightStyle">solid</property>
> <property name="borderRightWidth">1pt</property>
> <property name="borderTopColor">#CCCCCC</property>
> <property name="borderTopStyle">solid</property>
> <property name="borderTopWidth">1pt</property>
> </style>
> <style name="crosstab-cell" id="6">
> <property name="borderBottomColor">#CCCCCC</property>
> <property name="borderBottomStyle">solid</property>
> <property name="borderBottomWidth">1pt</property>
> <property name="borderLeftColor">#CCCCCC</property>
> <property name="borderLeftStyle">solid</property>
> <property name="borderLeftWidth">1pt</property>
> <property name="borderRightColor">#CCCCCC</property>
> <property name="borderRightStyle">solid</property>
> <property name="borderRightWidth">1pt</property>
> <property name="borderTopColor">#CCCCCC</property>
> <property name="borderTopStyle">solid</property>
> <property name="borderTopWidth">1pt</property>
> </style>
> </styles>
> <page-setup>
> <simple-master-page name="Simple MasterPage" id="2">
> <property name="topMargin">0.25in</property>
> <property name="leftMargin">0.25in</property>
> <property name="bottomMargin">0.25in</property>
> <property name="rightMargin">0.25in</property>
> <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="103">
> <property name="width">100%</property>
> <property name="dataSet">EmpDS</property>
> <list-property name="boundDataColumns">
> <structure>
> <property name="name">EmpID</property>
> <expression
> name="expression">dataSetRow["EmpID"]</expression>
> <property name="dataType">string</property>
> </structure>
> <structure>
> <property name="name">EmpName</property>
> <expression
> name="expression">dataSetRow["EmpName"]</expression>
> <property name="dataType">string</property>
> </structure>
> </list-property>
> <column id="110"/>
> <detail>
> <row id="106">
> <cell id="107">
> <data id="111">
> <property
> name="resultSetColumn">EmpName</property>
> </data>
> </cell>
> </row>
> </detail>
> </table>
> <table id="112">
> <property name="width">100%</property>
> <property name="dataSet">EmpDetailsDS</property>
> <list-property name="boundDataColumns">
> <structure>
> <property name="name">empComp</property>
> <expression
> name="expression">dataSetRow["empComp"]</expression>
> <property name="dataType">string</property>
> </structure>
> <structure>
> <property name="name">empyrs</property>
> <expression
> name="expression">dataSetRow["empyrs"]</expression>
> <property name="dataType">string</property>
> </structure>
> </list-property>
> <column id="122"/>
> <column id="123"/>
> <header>
> <row id="113">
> <cell id="114">
> <label id="125">
> <text-property
> name="text">empComp</text-property>
> </label>
> </cell>
> <cell id="115">
> <label id="127">
> <text-property
> name="text">empyrs</text-property>
> </label>
> </cell>
> </row>
> </header>
> <detail>
> <row id="116">
> <cell id="117">
> <data id="126">
> <property
> name="resultSetColumn">empComp</property>
> </data>
> </cell>
> <cell id="118">
> <data id="128">
> <property
> name="resultSetColumn">empyrs</property>
> </data>
> </cell>
> </row>
> </detail>
> <footer>
> <row id="119">
> <cell id="120"/>
> <cell id="121"/>
> </row>
> </footer>
> </table>
> </body>
> </report>
>
> ************************************************************ ***************
> my source file --- empRep.Java
> (A simple file creating two arraylists)
>
>
> import java.util.ArrayList;
> import java.util.HashMap;
>
>
>
> public class empRep {
>
> private String empName ="";
> private String empComp = "";
> private String empYrs = "";
> ArrayList empList=new ArrayList();
> ArrayList empDetList =new ArrayList();
>
> public String getEmpName() {
> return empName;
> }
>
> public String getEmpComp() {
> return empComp;
> }
>
> public String getEmpYrs() {
> return empYrs;
> }
>
> public void setEmpName(String empName) {
> this.empName =empName ;
> }
>
> public void setEmpComp(String empComp) {
> this.empComp =empComp ;
> }
>
> public void setEmpYrs(String empYrs) {
> this.empYrs =empYrs ;
> }
>
> public ArrayList getEmpList() {
> return empList;
> }
>
> public ArrayList getEmpDetList() {
> return empDetList;
> }
>
> public void generateData() {
> empRep empRepObj=new empRep();
> empRep empRepObj1 = new empRep();
> for(int i=1;i<4;i++) {
> empRepObj1 = new empRep();
> empRepObj1.setEmpName("Emp"+i);
> empList.add(empRepObj1);
> for(int k=0;k<3;k++) {
> empRepObj = new empRep();
> empRepObj.setEmpComp("EmpComp"+ i+k);
> empRepObj.setEmpYrs("EmpYrs" +i+ k);
> empDetList.add(empRepObj);
> }
>
> }
> }
>
>
> }
>
> ************************************************************ ***********
> In the main()
>
>
> empRep empRep1=new empRep();
> empRep1.generateData();
> List empList = empRep1.getEmpList();
> List empDetailsList =empRep1.getEmpDetList();
>
> IReportEngine engine = configureBirtEngine();
> IReportRunnable design = null;
>
> // Open the report design
> design = engine.openReportDesign(RPTBASEPATH + ReportName
> + WebReport.RPTExtension);
>
> IRunAndRenderTask runRenderTask = engine.createRunAndRenderTask(design);
>
> RenderOption options = new RenderOption();
> options.setOutputFileName(RPTOUTPUTDIR + ReportName + ".pdf");
>
> // Set output format
> options.setOutputFormat(".pdf");
> runRenderTask.setRenderOption(options);
>
> EngineConfig config = new EngineConfig();
> HashMap hm = config.getAppContext();
> hm.put("EmpDS", empList);
> hm.put("EmpDetailsDS", empDetailsList);
>
> runRenderTask.setAppContext(hm);
> runAndRenderReport(runRenderTask, engine);
>
>
> Thanks in Advance
> Roopa
>
>
Re: Iterating the ArrayList within another ArrayList [message #368841 is a reply to message #368761] Tue, 30 June 2009 12:25 Go to previous messageGo to next message
Roopa  is currently offline Roopa Friend
Messages: 20
Registered: July 2009
Junior Member
Jason,

I tried with the way, as explained above.
But now , am able to see only few rows in the inner list.
In my test data , I have 4 employee objects in the outer map.
And each emplyee has 3 objects in the inner map.
In the log, it displays all the records . But in the pdf,it is displaying
all the 4 employee names from the outer map and from the inner map, it is
fetching only the last object from each of the employees.
Am attaching the code below. Below advice, if am missing out something
anywhere.

******************************** xml code :

<?xml version="1.0" encoding="UTF-8"?>
<report xmlns="http://www.eclipse.org/birt/2005/design" version="3.2.17"
id="1">
<property name="createdBy">Eclipse BIRT Designer Version
2.3.2.r232_20081120 Build &lt;2.3.2.v20081128-0730></property>
<property name="units">in</property>
<method name="initialize"><![CDATA[importPackage( Packages.java.util );
importPackage( Packages.java.lang );

var outerMap = new Hashtable();
var innerMap = new Hashtable();

System.out.print("in the initialise");


var indx=0;
innerMap =EmpDetailsDS;
outerIter = EmpDS.iterator();
while(outerIter.hasNext()){
outerObj =outerIter.next();
outerMap.put(indx, outerObj.getEmpName());
System.out.println("outerObj:" + outerObj.getEmpName());
indx++;
}


reportContext.setPersistentGlobalVariable("outerMap", outerMap);
System.out.println(outerMap.size());
reportContext.setPersistentGlobalVariable("innerMap", innerMap);
System.out.println(innerMap.size());
count =0;]]></method>
<property name="iconFile">/templates/blank_report.gif</property>
<property name="bidiLayoutOrientation">ltr</property>
<data-sources>
<script-data-source name="EmpDS" id="24"/>
</data-sources>
<data-sets>
<script-data-set name="EmpDS" id="25">
<list-property name="resultSetHints">
<structure>
<property name="position">0</property>
<property name="name">EmpID</property>
<property name="dataType">string</property>
</structure>
<structure>
<property name="position">1</property>
<property name="name">EmpName</property>
<property name="dataType">string</property>
</structure>
</list-property>
<list-property name="columnHints">
<structure>
<property name="columnName">EmpID</property>
</structure>
<structure>
<property name="columnName">EmpName</property>
</structure>
</list-property>
<structure name="cachedMetaData">
<list-property name="resultSet">
<structure>
<property name="position">1</property>
<property name="name">EmpID</property>
<property name="dataType">string</property>
</structure>
<structure>
<property name="position">2</property>
<property name="name">EmpName</property>
<property name="dataType">string</property>
</structure>
</list-property>
</structure>
<property name="dataSource">EmpDS</property>
<method name="open"><![CDATA[System.out.print("in the outer
open");
hMap = reportContext.getPersistentGlobalVariable("outerMap");
iter = hMap.entrySet().iterator();
]]></method>
<method name="fetch"><![CDATA[if( iter.hasNext() ){
myObject = iter.next();
row["EmpName"] = myObject;
System.out.print("in outerfetch: row[EmpName] " + row["EmpName"]);
return true;

}else{

return false;

}]]></method>
</script-data-set>
<script-data-set name="EmpDetailsDS" id="26">
<list-property name="resultSetHints">
<structure>
<property name="position">1</property>
<property name="name">empComp</property>
<property name="dataType">string</property>
</structure>
<structure>
<property name="position">2</property>
<property name="name">empyrs</property>
<property name="dataType">string</property>
</structure>
<structure>
<property name="position">3</property>
<property name="name">EmpName</property>
<property name="dataType">string</property>
</structure>
</list-property>
<list-property name="columnHints">
<structure>
<property name="columnName">empComp</property>
</structure>
<structure>
<property name="columnName">empyrs</property>
</structure>
<structure>
<property name="columnName">EmpName</property>
</structure>
</list-property>
<structure name="cachedMetaData">
<list-property name="resultSet">
<structure>
<property name="position">1</property>
<property name="name">empComp</property>
<property name="dataType">string</property>
</structure>
<structure>
<property name="position">2</property>
<property name="name">empyrs</property>
<property name="dataType">string</property>
</structure>
<structure>
<property name="position">3</property>
<property name="name">EmpName</property>
<property name="dataType">string</property>
</structure>
</list-property>
</structure>
<property name="dataSource">EmpDS</property>
<list-property name="parameters">
<structure>
<property name="name">inputParm1</property>
<property name="dataType">string</property>
<property name="position">1</property>
<expression name="defaultValue">""</expression>
<property name="isInput">true</property>
<property name="isOutput">true</property>
</structure>
</list-property>
<method name="open"><![CDATA[i = 0;
System.out.println("inner open");
EmpObj = inputParams["inputParm1"];
empObj1= EmpObj.toString().substring(4,8);
System.out.println("EmpNameObj" +empObj1);

]]></method>
<method name="fetch"><![CDATA[System.out.println("inner
fetch");
iMap = reportContext.getPersistentGlobalVariable("innerMap");
inObj = iMap.get(empObj1);

System.out.println( "inObj.size(): " + inObj.size());
System.out.println("i" + i);
if( i > 0 )
{
System.out.println("i" + i);
return false;
}

if( inObj != null ){
iter1=inObj.iterator();
while(iter1.hasNext()){
eObj=iter1.next();
row["empComp"] = eObj.getEmpComp();
row["empyrs"] = eObj.getEmpYrs();
System.out.println( "row[empComp] " + row["empComp"]);
System.out.println( "row[empyrs] " + row["empyrs"]);
}
}
else{
System.out.print("inner obj is null");
}


i++
return true;]]></method>
</script-data-set>
</data-sets>
<styles>
<style name="report" id="4">
<property name="fontFamily">"Verdana"</property>
<property name="fontSize">10pt</property>
</style>
<style name="crosstab" id="5">
<property name="borderBottomColor">#CCCCCC</property>
<property name="borderBottomStyle">solid</property>
<property name="borderBottomWidth">1pt</property>
<property name="borderLeftColor">#CCCCCC</property>
<property name="borderLeftStyle">solid</property>
<property name="borderLeftWidth">1pt</property>
<property name="borderRightColor">#CCCCCC</property>
<property name="borderRightStyle">solid</property>
<property name="borderRightWidth">1pt</property>
<property name="borderTopColor">#CCCCCC</property>
<property name="borderTopStyle">solid</property>
<property name="borderTopWidth">1pt</property>
</style>
<style name="crosstab-cell" id="6">
<property name="borderBottomColor">#CCCCCC</property>
<property name="borderBottomStyle">solid</property>
<property name="borderBottomWidth">1pt</property>
<property name="borderLeftColor">#CCCCCC</property>
<property name="borderLeftStyle">solid</property>
<property name="borderLeftWidth">1pt</property>
<property name="borderRightColor">#CCCCCC</property>
<property name="borderRightStyle">solid</property>
<property name="borderRightWidth">1pt</property>
<property name="borderTopColor">#CCCCCC</property>
<property name="borderTopStyle">solid</property>
<property name="borderTopWidth">1pt</property>
</style>
</styles>
<page-setup>
<simple-master-page name="Simple MasterPage" id="2">
<property name="topMargin">0.25in</property>
<property name="leftMargin">0.25in</property>
<property name="bottomMargin">0.25in</property>
<property name="rightMargin">0.25in</property>
<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="154">
<property name="width">100%</property>
<property name="dataSet">EmpDS</property>
<list-property name="boundDataColumns">
<structure>
<property name="name">EmpID</property>
<expression
name="expression">dataSetRow["EmpID"]</expression>
<property name="dataType">string</property>
</structure>
<structure>
<property name="name">EmpName</property>
<expression
name="expression">dataSetRow["EmpName"]</expression>
<property name="dataType">string</property>
</structure>
</list-property>
<column id="161"/>
<group id="199">
<property name="groupName">group1</property>
<property name="interval">none</property>
<property name="sortDirection">asc</property>
<expression name="keyExpr">row["EmpName"]</expression>
<property name="repeatHeader">false</property>
<property name="hideDetail">false</property>
<property name="pageBreakAfter">auto</property>
<property name="pageBreakBefore">auto</property>
<property name="pageBreakInside">auto</property>
<header>
<row id="200">
<cell id="201">
<data id="204">
<property
name="resultSetColumn">EmpName</property>
</data>
</cell>
</row>
</header>
<footer>
<row id="202">
<cell id="203"/>
</row>
</footer>
</group>
<detail>
<row id="164">
<cell id="165">
<table id="166">
<property name="width">100%</property>
<property
name="dataSet">EmpDetailsDS</property>
<list-property name="paramBindings">
<structure>
<property
name="paramName">inputParm1</property>
<expression
name="expression">row["EmpName"]</expression>
</structure>
</list-property>
<list-property name="boundDataColumns">
<structure>
<property
name="name">empComp</property>
<expression
name="expression">dataSetRow["empComp"]</expression>
<property
name="dataType">string</property>
</structure>
<structure>
<property name="name">empyrs</property>
<expression
name="expression">dataSetRow["empyrs"]</expression>
<property
name="dataType">string</property>
</structure>
<structure>
<property
name="name">EmpName</property>
<expression
name="expression">dataSetRow["EmpName"]</expression>
<property
name="dataType">string</property>
</structure>
</list-property>
<column id="176"/>
<column id="177"/>
<group id="205">
<property
name="groupName">group2</property>
<property name="interval">none</property>
<property
name="sortDirection">asc</property>
<expression
name="keyExpr">row["EmpName"]</expression>
<property
name="repeatHeader">true</property>
<property
name="hideDetail">false</property>
<property
name="pageBreakAfter">auto</property>
<property
name="pageBreakBefore">auto</property>
<property
name="pageBreakInside">auto</property>
<footer>
<row id="209">
<cell id="210"/>
<cell id="211"/>
</row>
</footer>
</group>
<detail>
<row id="170">
<cell id="171">
<data id="178">
<property
name="resultSetColumn">empComp</property>
</data>
</cell>
<cell id="172">
<data id="179">
<property
name="resultSetColumn">empyrs</property>
</data>
</cell>
</row>
</detail>
<footer>
<row id="173">
<cell id="174"/>
<cell id="175"/>
</row>
</footer>
</table>
</cell>
</row>
</detail>
<footer>
<row id="159">
<cell id="160"/>
</row>
</footer>
</table>
</body>
</report>

*********************************************************jav a code :


import java.util.ArrayList;
import java.util.HashMap;

import com.hhn.data.Report;
import com.hhn.data.ReportParameters;

public class empRep extends Report{

private String empName ="";
private String empComp = "";
private String empYrs = "";
ArrayList empList=new ArrayList();
ArrayList empDetList =new ArrayList();
public HashMap empDetMap =new HashMap();

public String getEmpName() {
return empName;
}

public String getEmpComp() {
return empComp;
}

public String getEmpYrs() {
return empYrs;
}

public void setEmpName(String empName) {
this.empName =empName ;
}

public void setEmpComp(String empComp) {
this.empComp =empComp ;
}

public void setEmpYrs(String empYrs) {
this.empYrs =empYrs ;
}

public ArrayList getEmpList() {
return empList;
}

public ArrayList getEmpDetList() {
return empDetList;
}

public void generateData() {
empRep empRepObj=new empRep();
empRep empRepObj1 = new empRep();
for(int i=0;i<4;i++) {
empRepObj1 = new empRep();
empRepObj1.setEmpName("Emp"+i);
empList.add(empRepObj1);
ArrayList temp = new ArrayList();
for(int k=0;k<3;k++) {
empRepObj = new empRep();
empRepObj.setEmpName("Emp"+i+""+k);
empRepObj.setEmpComp("EmpComp"+ i+k);
empRepObj.setEmpYrs("EmpYrs" +i+ k);
//empDetList.add(empRepObj);
temp.add(empRepObj);
}
empDetMap.put("Emp"+i, temp);
}
}

Thanks ,
Roopa.
Re: Iterating the ArrayList within another ArrayList [message #368846 is a reply to message #368841] Tue, 30 June 2009 18:36 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: jasonweathersby.windstream.net

Roopa,

On your internal fetch method you are iterating over the results without
returning. You need to return for each row not the entire dataset.
Something like:

iter1=inObj.iterator();
if(iter1.hasNext()){
eObj=iter1.next();
row["empComp"] = eObj.getEmpComp();
row["empyrs"] = eObj.getEmpYrs();
System.out.println( "row[empComp] " + row["empComp"]);
System.out.println( "row[empyrs] " + row["empyrs"]);
return true;
}
return false;

Jason

Roopa wrote:
> Jason,
>
> I tried with the way, as explained above.
> But now , am able to see only few rows in the inner list.
> In my test data , I have 4 employee objects in the outer map.
> And each emplyee has 3 objects in the inner map.
> In the log, it displays all the records . But in the pdf,it is
> displaying all the 4 employee names from the outer map and from the
> inner map, it is fetching only the last object from each of the employees.
> Am attaching the code below. Below advice, if am missing out something
> anywhere.
>
> ******************************** xml code :
>
> <?xml version="1.0" encoding="UTF-8"?>
> <report xmlns="http://www.eclipse.org/birt/2005/design" version="3.2.17"
> id="1">
> <property name="createdBy">Eclipse BIRT Designer Version
> 2.3.2.r232_20081120 Build &lt;2.3.2.v20081128-0730></property>
> <property name="units">in</property>
> <method name="initialize"><![CDATA[importPackage( Packages.java.util );
> importPackage( Packages.java.lang );
>
> var outerMap = new Hashtable();
> var innerMap = new Hashtable();
>
> System.out.print("in the initialise");
>
>
> var indx=0;
> innerMap =EmpDetailsDS;
> outerIter = EmpDS.iterator();
> while(outerIter.hasNext()){
> outerObj =outerIter.next();
> outerMap.put(indx, outerObj.getEmpName());
> System.out.println("outerObj:" + outerObj.getEmpName());
> indx++;
> }
>
>
> reportContext.setPersistentGlobalVariable("outerMap", outerMap);
> System.out.println(outerMap.size());
> reportContext.setPersistentGlobalVariable("innerMap", innerMap);
> System.out.println(innerMap.size());
> count =0;]]></method>
> <property name="iconFile">/templates/blank_report.gif</property>
> <property name="bidiLayoutOrientation">ltr</property>
> <data-sources>
> <script-data-source name="EmpDS" id="24"/>
> </data-sources>
> <data-sets>
> <script-data-set name="EmpDS" id="25">
> <list-property name="resultSetHints">
> <structure>
> <property name="position">0</property>
> <property name="name">EmpID</property>
> <property name="dataType">string</property>
> </structure>
> <structure>
> <property name="position">1</property>
> <property name="name">EmpName</property>
> <property name="dataType">string</property>
> </structure>
> </list-property>
> <list-property name="columnHints">
> <structure>
> <property name="columnName">EmpID</property>
> </structure>
> <structure>
> <property name="columnName">EmpName</property>
> </structure>
> </list-property>
> <structure name="cachedMetaData">
> <list-property name="resultSet">
> <structure>
> <property name="position">1</property>
> <property name="name">EmpID</property>
> <property name="dataType">string</property>
> </structure>
> <structure>
> <property name="position">2</property>
> <property name="name">EmpName</property>
> <property name="dataType">string</property>
> </structure>
> </list-property>
> </structure>
> <property name="dataSource">EmpDS</property>
> <method name="open"><![CDATA[System.out.print("in the outer
> open");
> hMap = reportContext.getPersistentGlobalVariable("outerMap");
> iter = hMap.entrySet().iterator();
> ]]></method>
> <method name="fetch"><![CDATA[if( iter.hasNext() ){
> myObject = iter.next();
> row["EmpName"] = myObject;
> System.out.print("in outerfetch: row[EmpName] " + row["EmpName"]);
> return true;
>
> }else{
>
> return false;
>
> }]]></method>
> </script-data-set>
> <script-data-set name="EmpDetailsDS" id="26">
> <list-property name="resultSetHints">
> <structure>
> <property name="position">1</property>
> <property name="name">empComp</property>
> <property name="dataType">string</property>
> </structure>
> <structure>
> <property name="position">2</property>
> <property name="name">empyrs</property>
> <property name="dataType">string</property>
> </structure>
> <structure>
> <property name="position">3</property>
> <property name="name">EmpName</property>
> <property name="dataType">string</property>
> </structure>
> </list-property>
> <list-property name="columnHints">
> <structure>
> <property name="columnName">empComp</property>
> </structure>
> <structure>
> <property name="columnName">empyrs</property>
> </structure>
> <structure>
> <property name="columnName">EmpName</property>
> </structure>
> </list-property>
> <structure name="cachedMetaData">
> <list-property name="resultSet">
> <structure>
> <property name="position">1</property>
> <property name="name">empComp</property>
> <property name="dataType">string</property>
> </structure>
> <structure>
> <property name="position">2</property>
> <property name="name">empyrs</property>
> <property name="dataType">string</property>
> </structure>
> <structure>
> <property name="position">3</property>
> <property name="name">EmpName</property>
> <property name="dataType">string</property>
> </structure>
> </list-property>
> </structure>
> <property name="dataSource">EmpDS</property>
> <list-property name="parameters">
> <structure>
> <property name="name">inputParm1</property>
> <property name="dataType">string</property>
> <property name="position">1</property>
> <expression name="defaultValue">""</expression>
> <property name="isInput">true</property>
> <property name="isOutput">true</property>
> </structure>
> </list-property>
> <method name="open"><![CDATA[i = 0;
> System.out.println("inner open");
> EmpObj = inputParams["inputParm1"];
> empObj1= EmpObj.toString().substring(4,8);
> System.out.println("EmpNameObj" +empObj1);
>
> ]]></method>
> <method name="fetch"><![CDATA[System.out.println("inner fetch");
> iMap = reportContext.getPersistentGlobalVariable("innerMap");
> inObj = iMap.get(empObj1);
>
> System.out.println( "inObj.size(): " + inObj.size());
> System.out.println("i" + i);
> if( i > 0 )
> {
> System.out.println("i" + i);
> return false;
> }
>
> if( inObj != null ){
> iter1=inObj.iterator();
> while(iter1.hasNext()){
> eObj=iter1.next();
> row["empComp"] = eObj.getEmpComp();
> row["empyrs"] = eObj.getEmpYrs();
> System.out.println( "row[empComp] " + row["empComp"]);
> System.out.println( "row[empyrs] " + row["empyrs"]);
> }
> }
> else{
> System.out.print("inner obj is null");
> }
>
>
> i++
> return true;]]></method>
> </script-data-set>
> </data-sets>
> <styles>
> <style name="report" id="4">
> <property name="fontFamily">"Verdana"</property>
> <property name="fontSize">10pt</property>
> </style>
> <style name="crosstab" id="5">
> <property name="borderBottomColor">#CCCCCC</property>
> <property name="borderBottomStyle">solid</property>
> <property name="borderBottomWidth">1pt</property>
> <property name="borderLeftColor">#CCCCCC</property>
> <property name="borderLeftStyle">solid</property>
> <property name="borderLeftWidth">1pt</property>
> <property name="borderRightColor">#CCCCCC</property>
> <property name="borderRightStyle">solid</property>
> <property name="borderRightWidth">1pt</property>
> <property name="borderTopColor">#CCCCCC</property>
> <property name="borderTopStyle">solid</property>
> <property name="borderTopWidth">1pt</property>
> </style>
> <style name="crosstab-cell" id="6">
> <property name="borderBottomColor">#CCCCCC</property>
> <property name="borderBottomStyle">solid</property>
> <property name="borderBottomWidth">1pt</property>
> <property name="borderLeftColor">#CCCCCC</property>
> <property name="borderLeftStyle">solid</property>
> <property name="borderLeftWidth">1pt</property>
> <property name="borderRightColor">#CCCCCC</property>
> <property name="borderRightStyle">solid</property>
> <property name="borderRightWidth">1pt</property>
> <property name="borderTopColor">#CCCCCC</property>
> <property name="borderTopStyle">solid</property>
> <property name="borderTopWidth">1pt</property>
> </style>
> </styles>
> <page-setup>
> <simple-master-page name="Simple MasterPage" id="2">
> <property name="topMargin">0.25in</property>
> <property name="leftMargin">0.25in</property>
> <property name="bottomMargin">0.25in</property>
> <property name="rightMargin">0.25in</property>
> <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="154">
> <property name="width">100%</property>
> <property name="dataSet">EmpDS</property>
> <list-property name="boundDataColumns">
> <structure>
> <property name="name">EmpID</property>
> <expression
> name="expression">dataSetRow["EmpID"]</expression>
> <property name="dataType">string</property>
> </structure>
> <structure>
> <property name="name">EmpName</property>
> <expression
> name="expression">dataSetRow["EmpName"]</expression>
> <property name="dataType">string</property>
> </structure>
> </list-property>
> <column id="161"/>
> <group id="199">
> <property name="groupName">group1</property>
> <property name="interval">none</property>
> <property name="sortDirection">asc</property>
> <expression name="keyExpr">row["EmpName"]</expression>
> <property name="repeatHeader">false</property>
> <property name="hideDetail">false</property>
> <property name="pageBreakAfter">auto</property>
> <property name="pageBreakBefore">auto</property>
> <property name="pageBreakInside">auto</property>
> <header>
> <row id="200">
> <cell id="201">
> <data id="204">
> <property
> name="resultSetColumn">EmpName</property>
> </data>
> </cell>
> </row>
> </header>
> <footer>
> <row id="202">
> <cell id="203"/>
> </row>
> </footer>
> </group>
> <detail>
> <row id="164">
> <cell id="165">
> <table id="166">
> <property name="width">100%</property>
> <property name="dataSet">EmpDetailsDS</property>
> <list-property name="paramBindings">
> <structure>
> <property
> name="paramName">inputParm1</property>
> <expression
> name="expression">row["EmpName"]</expression>
> </structure>
> </list-property>
> <list-property name="boundDataColumns">
> <structure>
> <property name="name">empComp</property>
> <expression
> name="expression">dataSetRow["empComp"]</expression>
> <property
> name="dataType">string</property>
> </structure>
> <structure>
> <property name="name">empyrs</property>
> <expression
> name="expression">dataSetRow["empyrs"]</expression>
> <property
> name="dataType">string</property>
> </structure>
> <structure>
> <property name="name">EmpName</property>
> <expression
> name="expression">dataSetRow["EmpName"]</expression>
> <property
> name="dataType">string</property>
> </structure>
> </list-property>
> <column id="176"/>
> <column id="177"/>
> <group id="205">
> <property name="groupName">group2</property>
> <property name="interval">none</property>
> <property
> name="sortDirection">asc</property>
> <expression
> name="keyExpr">row["EmpName"]</expression>
> <property
> name="repeatHeader">true</property>
> <property name="hideDetail">false</property>
> <property
> name="pageBreakAfter">auto</property>
> <property
> name="pageBreakBefore">auto</property>
> <property
> name="pageBreakInside">auto</property>
> <footer>
> <row id="209">
> <cell id="210"/>
> <cell id="211"/>
> </row>
> </footer>
> </group>
> <detail>
> <row id="170">
> <cell id="171">
> <data id="178">
> <property
> name="resultSetColumn">empComp</property>
> </data>
> </cell>
> <cell id="172">
> <data id="179">
> <property
> name="resultSetColumn">empyrs</property>
> </data>
> </cell>
> </row>
> </detail>
> <footer>
> <row id="173">
> <cell id="174"/>
> <cell id="175"/>
> </row>
> </footer>
> </table>
> </cell>
> </row>
> </detail>
> <footer>
> <row id="159">
> <cell id="160"/>
> </row>
> </footer>
> </table>
> </body>
> </report>
>
> *********************************************************jav a code :
>
>
> import java.util.ArrayList;
> import java.util.HashMap;
>
> import com.hhn.data.Report;
> import com.hhn.data.ReportParameters;
>
> public class empRep extends Report{
>
> private String empName ="";
> private String empComp = "";
> private String empYrs = "";
> ArrayList empList=new ArrayList();
> ArrayList empDetList =new ArrayList();
> public HashMap empDetMap =new HashMap();
>
> public String getEmpName() {
> return empName;
> }
>
> public String getEmpComp() {
> return empComp;
> }
>
> public String getEmpYrs() {
> return empYrs;
> }
>
> public void setEmpName(String empName) {
> this.empName =empName ;
> }
>
> public void setEmpComp(String empComp) {
> this.empComp =empComp ;
> }
>
> public void setEmpYrs(String empYrs) {
> this.empYrs =empYrs ;
> }
>
> public ArrayList getEmpList() {
> return empList;
> }
>
> public ArrayList getEmpDetList() {
> return empDetList;
> }
>
> public void generateData() {
> empRep empRepObj=new empRep();
> empRep empRepObj1 = new empRep();
> for(int i=0;i<4;i++) {
> empRepObj1 = new empRep();
> empRepObj1.setEmpName("Emp"+i);
> empList.add(empRepObj1);
> ArrayList temp = new ArrayList();
> for(int k=0;k<3;k++) {
> empRepObj = new empRep();
> empRepObj.setEmpName("Emp"+i+""+k);
> empRepObj.setEmpComp("EmpComp"+ i+k);
> empRepObj.setEmpYrs("EmpYrs" +i+ k);
> //empDetList.add(empRepObj);
> temp.add(empRepObj);
> }
> empDetMap.put("Emp"+i, temp);
> }
> }
>
> Thanks ,
> Roopa.
>
Re: Iterating the ArrayList within another ArrayList [message #368851 is a reply to message #368846] Wed, 01 July 2009 07:34 Go to previous message
Roopa  is currently offline Roopa Friend
Messages: 20
Registered: July 2009
Junior Member
Jason,

Thank you so much for the help.
It worked.

Thanks,
Roopa.
Previous Topic:Chart Grouping problem BIRT 2.3
Next Topic:Datatype "Any" in 2.3.2
Goto Forum:
  


Current Time: Fri Apr 26 19:54:45 GMT 2024

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

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

Back to the top