|
Re: ArrayLists in scripted data sets [message #841700 is a reply to message #841310] |
Wed, 11 April 2012 16:31 |
|
Andrew,
I am attaching an example that does an arraylist of arraylist. I am
setting the data in the beforeFactory and using it in a scripted dataset.
In your example can your post the error you are getting? Also remove
the keyword var off of this line:
var theDataList = myPortfolio.fakeData;
Jason
On 4/11/2012 2:32 AM, andrew smith wrote:
> Hello, all:
>
> I was wondering if someone could please give me a hint on how to work
> with ArrayLists from Java in BIRT. Here is my situation:
>
> I have a very basic java code that creates an ArrayList of an ArrayList
> ie ArrayList<ArrayList<String>> ie 2d table and stores it as one of the
> properties of the java class.
>
> This ArrayList is used as a scripted data source to populate the data.
> In the 'open' section of the scripted data set, I have the following:
> importPackage(Packages.com.Portfolio); // does not trigger error
> importPackage(Packages.java.util); // does not trigger error
> importPackage(Packages.java.lang); // does not trigger error
>
> var myPortfolio = new Portfolio('111'); // does not trigger error
> var theDataList = myPortfolio.fakeData; // does not trigger error
> totalCount = myPortfolio.fakeData.get(0).size(); // does not trigger
> error - I get a good number here. counter=0; // does not trigger error
>
> In the fetch section I have: if (counter>=totalCount-1){
> return(false);} //does not trigger error
>
> var timeLine = new ArrayList(); //does not trigger error - Just declare
> an ArrayList in Birt
> timeLine = theDataList.get(0); //TRIGGERS AN ERROR
> //var rorList = theDataList.get(1);
> //row["Year"] = timeLine.get(counter);
> //row["Ror"] = rorList.get(counter);
> counter = counter+1;
> return (true);
>
> The error happens at timeLine = theDataList.get(0); theDataList is a 2d
> table (ArrayList of an ArrayList) so the theDataList.get(0) should
> return just a 1d ArrayList. BUT IT BREAKS HERE.
> What am I doing wrong?
> thanks in advance, Andrew
|
|
|
|
Re: ArrayLists in scripted data sets [message #842728 is a reply to message #842107] |
Thu, 12 April 2012 15:11 |
|
using var will scope it for just that event. Dropping var with make it
available to downstream events.
Jason
On 4/11/2012 10:06 PM, andrew smith wrote:
> Jason,
> Thank you very much for help and an example. When I removed the var from
> the line that you suggested, everything started to work. Your example
> that you attached further solidified my understanding. Thank you.
> Just one more quick question on 'var'. I was under impression that I
> should use 'var' when instantiating an object or a a variable...But it
> looks like I should not use 'var' when it comes to variables... is that so?
> Thanks again,
> Andrew
|
|
|
|
Powered by
FUDForum. Page generated in 0.02840 seconds