2006 IR Open Dicussion Posted August 27, 2006 Share Posted August 27, 2006 By: cyclistca - cyclistca Using an ArrayList as a datasource 2006-03-29 17:04 I've created my own class that implements JRDataSource. I've created an ArrayList in my Java application and sent it as a parameter value in my HashMap to the application. Now I want to us the ArrayList as the datasourse for my Subreport. How do I go about doing this? I can not figure out in the report how to point my subreport to the class that implements JRDataSource. How do I also get my class to point to the particular ArrayList that I am passing from my application to the report? By: jasperkan - jasperkannan RE: Using an ArrayList as a datasource 2006-03-31 14:40 u need to create an Object of type JRCollectionDataSource . U can pass a collection to the constructor of this class directly . in my case i m doing it from a scriptlet class as given below. net.sf.jasperreports.engine.data.JRMapCollectionDataSource map = (net.sf.jasperreports.engine.data.JRMapCollectionDataSource) this .getVariableValue("COLLECTION_DATASOURCE"); if (map==null) map = new JRMapCollectionDataSource(l); this.setVariableValue("MY_COLLECTION_DATASOURCE", map); Now u have this datasourcemap as a variable in ur report so u can pass this to a subreport as a datasource . instead of report connection , say Datasource and give the expression as $V{MY_COLLECTION_DATA_SOURCE} . 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