Jump to content
Changes to the Jaspersoft community edition download ×

Help a new person with DataSources

2004 IR Help

Recommended Posts

By: exabrial - exabrial

Help a new person with DataSources

2005-01-22 21:42

I must be completely retarded. I have spent 3 hours trying how to figure out to do this.


I designed a report with IReport. In I report, there is a field called "Cookie" that's a string. I attempt to display the entire contents field by putting, "$F{Cookie}" in the report.


Am I good so far?


Next, I want to fill that field from a set(hashset to be exact).



HashSet fields = new HashSet();


fields.add("Peanut Butter");


JRMapCollectionDataSource data = new JRMapCollectionDataSource(fields);



Now what do i do? I have this code, but it doesn't work. It throws a ClassCastException.



jasperPrint = jasperFillManager.fillReport(jasperReport,parameters, data);



Like i said, i must be stupid. Everyone else on the board seemed to figure this out... Thank you for any help.







By: David Lim - aberrant80

RE: Help a new person with DataSources

2005-01-24 01:41

You did two things wrong:


1) It's a JRMapCollectionDataSource. The word "Map" in the class name means a Set won't do.


2) A data source represents a collection a data that should be in a structure that resembles a table. Basically, for this class to work, your data source needs to be a map of maps. The inner maps are all keyed by the field names.


In you example, it should've been a map of 3 maps, where each of the inner map has one entry keyed by "Cookie".


Hope I'm clear enough.

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...