Skip to main content



      Home
Home » Archived » BIRT » Java collection as a Table data source??
Java collection as a Table data source?? [message #114226] Tue, 24 January 2006 09:51 Go to next message
Eclipse UserFriend
Hi!!

I'd like to use my Java object collection as a data source in a table.
Is it possible to do ??

I can send my collection to the report as a scriptableJavaObject but how
should I read it in my report ??


Regards, Wojtas
Re: Java collection as a Table data source?? [message #114262 is a reply to message #114226] Tue, 24 January 2006 10:20 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: abrunet1.gfi.fr

Hello,
in your java code, you must pass your collection as a
scriptableJavaObject.
in your report, you create a datasource with a script.
then you create a dataset which use the new datasource.
then you link your table with the new dataset.
then open your dataset in code view :
in open method :
var iterate = myCollection.iterator();
in fetch method :
if (!iterate .hasNext()) return false;
var person = new
Packages.com.my.package.Person(iteration.next());
row["name"] = person.getName();
row["phone"] = person.getPhone();
return true;

(replace Person by your class in your Collection).

You must have in your class Person a constructor like this:
public Personn(String name, String phone) {
this.name = name ....
}

if you don't understand something, ask it.

Bye

Wojtas wrote:

> Hi!!

> I'd like to use my Java object collection as a data source in a table.
> Is it possible to do ??

> I can send my collection to the report as a scriptableJavaObject but how
> should I read it in my report ??


> Regards, Wojtas
Re: Java collection as a Table data source?? [message #115143 is a reply to message #114262] Wed, 25 January 2006 02:36 Go to previous messageGo to next message
Eclipse UserFriend
Thank you for answer.

I'll try it today and let you know if it wors :-)


Regards
Re: Java collection as a Table data source?? [message #117365 is a reply to message #114262] Thu, 26 January 2006 07:01 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: xxx.xxx.com

thanks too, i try and that does work :

in my webapp :
task.addScriptableJavaObject("myCollectionObjectReport",myCollection);

my dataset :
in open method :

iterate = myCollectionObjectReport.iterator();
(and not with "var" like : var iterate =
myCollectionObjectReport.iterator();
why ? i don't know :D)

in fetch method :

if (!iterate.hasNext()) return false;
myObject = iterate.next();
row["myObject_code"] = myObject.getCode();
row["myObject_libelle"] = myObject.getLibelle();
return true;

(and not with "var" and "Packages.XX.XX" like : var myObject = new
Packages.com.my.package.MyObject (iteration.next());
why ? i don't know :D)

and my table link with the new dataset.

Regards.
Denis.
Re: Java collection as a Table data source?? [message #117567 is a reply to message #117365] Thu, 26 January 2006 11:05 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: abrunet1.gfi.fr

I don't understand in my case it doesn't work without
Packages.com.my.package.MyObject (iteration.next());

For 'var' key word, i have already the probleme in some case.

Which version of birt do you use ?

Regards.
Arnaud

Denis wrote:

> thanks too, i try and that does work :

> in my webapp :
> task.addScriptableJavaObject("myCollectionObjectReport",myCollection);

> my dataset :
> in open method :

> iterate = myCollectionObjectReport.iterator();
> (and not with "var" like : var iterate =
> myCollectionObjectReport.iterator();
> why ? i don't know :D)

> in fetch method :

> if (!iterate.hasNext()) return false;
> myObject = iterate.next();
> row["myObject_code"] = myObject.getCode();
> row["myObject_libelle"] = myObject.getLibelle();
> return true;

> (and not with "var" and "Packages.XX.XX" like : var myObject = new
> Packages.com.my.package.MyObject (iteration.next());
> why ? i don't know :D)

> and my table link with the new dataset.

> Regards.
> Denis.
Re: Java collection as a Table data source?? [message #117591 is a reply to message #117567] Thu, 26 January 2006 11:23 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: xxx.xxx.com

i use Report_Engine in my webapp, BIRT 2.0 RC1.

Denis.
Re: Java collection as a Table data source?? [message #117655 is a reply to message #117591] Thu, 26 January 2006 12:12 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: abrunet1.gfi.fr

I use birt 1.0.1 in a java application to generate PDF.
Re: Java collection as a Table data source?? [message #138091 is a reply to message #114226] Thu, 02 March 2006 09:36 Go to previous message
Eclipse UserFriend
test
Previous Topic:Using rptdesign file outside a Reportproject
Next Topic:Can't Run Report w/ Parameters
Goto Forum:
  


Current Time: Sun May 11 03:40:44 EDT 2025

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

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

Back to the top