Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » Problem with Scripted DataSource and POJOs(Java Beans and objects to populate a Report)
icon5.gif  Problem with Scripted DataSource and POJOs [message #520068] Thu, 11 March 2010 02:40 Go to next message
Ivan Hoe is currently offline Ivan HoeFriend
Messages: 12
Registered: March 2010
Junior Member
Hi there again!

I just love BIRT. The thing this time is that I don't know what item from the Palette to use to extract info from my JavaBean (It is a custom Object used to store iteration of data but also has not iterative info to place in the report that looks as a form layout).

The thing is I know (sort of) how to use the Scripted DataSource and followed the tutorial of this guy and I know how to place info from an Array of objects (in this case a List of DataSets).

My custom DataSet works in almost the same manner but let's say that I have a Bean holding as properties the name, age, sex, and so on of a fellow, and an iterative property of any number of let's say cars that guy owns. How complex do the scripts become with this approach? I know I would have a fetch just iterating the "cars names" and just bind that iteration with the dataSet in a row["xxx"] maner, but how do I deal with the non iterative content?

Guess it sounds a bit more complex than it should. I know most of my problem is lack of knowledge but even though I own the 2nd edition of the Field Guide to Reporting, no mention to Scripted Datasource is made.

Ivan
Re: Problem with Scripted DataSource and POJOs [message #520292 is a reply to message #520068] Thu, 11 March 2010 15:20 Go to previous message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Ivan,

there should be a chapter in the book on scripted dataset. You may also
want to check the dev share at birt-exchange.org. There are a lot of
examples there.

So in your example you could flatten the row like

personname
personsex
personrace
cartype
carmodel

Then use the car iterator to iterate over the rows and just set
personame (noniterative data every row. In most cases you will access
the bean in the beforeOpen and set it to a js var. Just do not use the
var keyword and the Fetch will have access to it.

beforeOpen
this:
mybean = calljavatogetmybean();
cariter = mybean.getCarIterator();
instead of:
var mybean = calljavatogetmybean();


fetch
if(cariter.hasNext() == false ){
return false;
}

var car= iterator.next();
row["personame"] = mybean.getName();
row["carmodel"] = car.getCarModel();

return true;



Jason


Ivan Hoe wrote:
> Hi there again!
>
> I just love BIRT. The thing this time is that I don't know what item
> from the Palette to use to extract info from my JavaBean (It is a custom
> Object used to store iteration of data but also has not iterative info
> to place in the report that looks as a form layout).
>
> The thing is I know (sort of) how to use the Scripted DataSource and
> followed the tutorial of
> http://www.vogella.de/articles/EclipseBIRT/article.html and I know how
> to place info from an Array of objects (in this case a List of DataSets).
>
> My custom DataSet works in almost the same manner but let's say that I
> have a Bean holding as properties the name, age, sex, and so on of a
> fellow, and an iterative property of any number of let's say cars that
> guy owns. How complex do the scripts become with this approach? I know I
> would have a fetch just iterating the "cars names" and just bind that
> iteration with the dataSet in a row["xxx"] maner, but how do I deal with
> the non iterative content?
>
> Guess it sounds a bit more complex than it should. I know most of my
> problem is lack of knowledge but even though I own the 2nd edition of
> the Field Guide to Reporting, no mention to Scripted Datasource is made.
>
> Ivan
Previous Topic:2.5.1 -> 2.5.2 Different result on stacked bar chart
Next Topic:JNDI DataSource question
Goto Forum:
  


Current Time: Fri Apr 26 16:08:50 GMT 2024

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

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

Back to the top