harv Posted January 6, 2010 Share Posted January 6, 2010 Hi,I'm having a few problems with a report containing some List components and could do with a bit of help.I am using the JRBeanCollectionDataSource as a datasource, this passes in a Bean which contains a number of <Lists>an example is:Faculty > Teacher A> StudentA StudentB StudentC Teacher B> StudentD StudentE StudentF Teacher C> StudentG StudentH StudentII need to display all the teachers and students and there is no way of knowing how many of either there will be. I have no problem passing in the <Faculty> object and displaying all the <Teacher> items but can't seem to find a way to display the <Student>. At the minute I am passing the faculty object as a parameter of type JRBeanCollectionDataSource into the report and using this with a list component via the associated datataset, it works fine, but when I try to insert a list comp to show the <Student> under each <Teacher> I get NullPointer compile errors.Can this even be done (as in list within list) and if not what are the alternatives list>Subreport or Subreport>Subreport. If it can be done I'm not clear how to pass the data between them, as I think the Faculty object is consumed by the first list it will not be available for any subreports or lists. BTW I'm using iReport 3.60.Thanks,Andrew. Link to comment Share on other sites More sharing options...
lshannon Posted January 6, 2010 Share Posted January 6, 2010 What is the datasource expression you are trying when you pass in the student list?I would think something like the datasource expression below would work:new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource(studentObjectArrayList) Link to comment Share on other sites More sharing options...
harv Posted January 7, 2010 Author Share Posted January 7, 2010 Thanks,yes, I can use that to pass the Sudent Collection as a datasource parameter to a list on the main report, but if I try to access it from a (sub)list I get compile errors as the subList does not appear to be able to 'see' the parameter. I am also not sure that passing this in as a parameter to the main report will work as each student list will have to be associated with a single teacher...I have tried to pass it in as a parameter to the dataset used by the list but this does not seem to work either.Regards,Andrew. Link to comment Share on other sites More sharing options...
lshannon Posted January 7, 2010 Share Posted January 7, 2010 Rather than a parameter I was suggesting doing this in the datasource expression for the list.In iReport if you right click on the list element in the design and select "edit list datasource" you will be presented with a pop up to configure the datasource. Make sure "Use Datasource expression" is selected in the Connection/Datasource expression combo box and place something like this as the expression:new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource(studentObjectArrayList) 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