Jump to content
Changes to the Jaspersoft community edition download ×

JR custom dataSource with EJBs


Recommended Posts

By: Michael Greer - michaelggreer

JR custom dataSource with EJBs

2002-11-08 13:25

I do not have (or want) direct access to the database. I retrieve objects from the EJBs. How, therefore, do I implement a custom datasource to do this? The sample datasource is quite simplistic (hardcoded strings), and it is hard to infer from it how to do a real implementation.

 

My real question, I guess, is how to dynamically populate the datasource. The API for JRDataSource has no methods for filling the data, otherwise I would fill it myself before passing it. Am I missing something? The datasource can, of course, retrieve the objects from the EJBs, but not unless I tell it what to get. How do, for example, pass it productId=233, so it can look up all customers who ordered productId==233?

 

thank you,

Michael Greer

 

 

By: Teodor Danciu - teodord

RE: JR custom dataSource with EJBs

2002-11-08 13:40

 

Hi,

 

No, it is not like that.

 

In order to create a custom data source you

have to implement only two methods.

 

The next() method is called by the reporting engine

so that your data source move the internal pointer

to the next virtual record.

 

The getFieldValue() is called by the reporting engine

to retrieve the values for each data source field.

It would be like saying:

"Hey, give me the value of this field called ProductName"

And your data source has to know how to get this

value for the reporting engine.

 

You tell me that you are using EJBs.

Then I thing your data is represented mainly by

collections of beans.

In this case, you should take a look at the

dori.jasper.engine.data.JRBeanCollectionDataSource

which uses reflection to retrieve field data.

 

The "datasource" sample is not irrelevant.

It is a simple example that should be enough to get

the idea.

As you can see, the data source receives

its data through the constructor. In fact, it only

wraps already created collections of objects.

 

Of course, in your implementation you won't be

using static data, like I do in this sample.

Your data would be dynamic, retrieved using

finders and stuff.

But what would you expect from a sample that

should run on any machine?

 

I hope this helps.

Teodor

 

 

 

By: Michael Greer - michaelggreer

RE: JR custom dataSource with EJBs

2002-11-11 09:16

Didn't mean to disparage your example. I think I get it now.

 

thanks,

Michael Greer

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...