2004 IR Help Posted August 20, 2006 Share Posted August 20, 2006 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). <code> HashSet fields = new HashSet(); fields.add("Chocolate"); fields.add("Peanut Butter"); fields.add("Oatmeal"); JRMapCollectionDataSource data = new JRMapCollectionDataSource(fields); </code> Now what do i do? I have this code, but it doesn't work. It throws a ClassCastException. <code> jasperPrint = jasperFillManager.fillReport(jasperReport,parameters, data); </code> Like i said, i must be stupid. Everyone else on the board seemed to figure this out... Thank you for any help. -Jon 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now