Plugins (1071)


Training and Consulting (41)



EPIC Poll

What is your favourite developer portal?

[ Results | Polls ]

Votes: 539
Comments: 0

Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
ens
Post subject: Missing the First line of a subreport  PostPosted: Jul 25, 2006 - 03:53 PM
Guest





Hello,

I'm having a problem with JasperReports 1.2.5. I'm trying to generate a report with a subreport in it, using J2EE + Struts. I take a connection from database and generate a Collection, and then I send it to the JasperReport using JRBeanCollectionDataSource class. Everything works fine, but the subreport does not show the first line of the Collection, it just jumps to the second line of Collection, and generates the rest of the pdf file. Does anyone ever passed by a situation like this? How can I solve this problem?

Thanks for any help.
 
   
Reply with quote Back to top
Guest
Post subject: RE: Missing the First line of a subreport  PostPosted: Jul 26, 2006 - 02:31 PM






try www.gissystems.net
 
   
Reply with quote Back to top
ens
Post subject: RE: Missing the First line of a subreport  PostPosted: Jul 26, 2006 - 03:02 PM
Guest





I already generate the report, but the problem is the first element missing in the begining of subreport. The report is correctly generated in the application, but it misses the first element of collection. As I said, I'm using JRBeanCollectionDataSource class to bring data to subreport. How can I solve this problem?

Thanks for any help.
 
   
Reply with quote Back to top
Guest
Post subject: RE: Missing the First line of a subreport  PostPosted: Jul 26, 2006 - 04:24 PM






Hello,

I have found a solution: Add a empty bean to the collection. After that, the JRBeanCollectionDataSource have read correctly the list of beans from collection. I think that JRBeanCollectionDataSource begins countting the Collection object from 1 and not from 0.

Thanks for your attention
 
   
Reply with quote Back to top
madhur_swaroop
Post subject: Re: RE: Missing the First line of a subreport  PostPosted: Jan 28, 2008 - 04:07 PM



Joined: Jan 28, 2008
Posts: 1

Hi,
I am trying to create PDF using iReport and JasperReports. I have 2 classes, 'Student' and 'Course'. Student class and can contain multiple Course(es).

package com.subreports;
public class Student {
String id;
String firstName;
String lastName;
String age;
List coursesTaken;

public Student() {}

public Student(String id, String firstName, String lastName, String age) {
this.id = id;
this.firstName = firstName;
this.lastName = lastName;
this.age = age;
}

public static List createBeanCollection(){
List list = new ArrayList ();
Student student = new Student("01","ABC", "XYZ", "20");

List al = new ArrayList();
al.add(new Course("01","0001", "Investment Banking"));
al.add(new Course("01","0002", "Marketing"));
student.setCoursesTaken(al);

list.add(student);
return list;
}
//all getters and setters defined here....
}

package com.subreports;
public class Course {
String studentID;
String courseID;
String courseName;

public Course() {}

public Course(String studentID, String courseID, String courseName) {
super();
this.studentID = studentID;
this.courseID = courseID;
this.courseName = courseName;
}
//all getters and setters are defined here
}

I complied these classes and put the jar file containing these 2 classes into 'lib' folder of iReport.
I created Master and inserted subReport. In master report I passed the following parameter to subReport
SubReport Parameter Name: coursesTaken
Default value Expression: new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($F{coursesTaken})

In subReport I defined ONE Parameter named 'coursesTaken' of type 'java.util.Collection'. I also defined 3 Fields namely 'studentID', 'courseID' and 'courseName' and also dropped these fields in 'Detail' section of report.

Complied both classes. When I try to run Master report. I receive below error:
Error filling print... net.sf.jasperreports.engine.JRException: Incompatible net.sf.jasperreports.engine.data.JRBeanCollectionDataSource value assigned to parameter coursesTaken in the Student-Test_subreport0 dataset.

Please help me if you know why I am receiving this error and How to rectify this.

I am trying to display all the courses corresponding to each student as sub report. I am receiving data in the form mentioned like Student and Course. I can not change that.

Thanks in advance.


Anonymous wrote:
Hello,

I have found a solution: Add a empty bean to the collection. After that, the JRBeanCollectionDataSource have read correctly the list of beans from collection. I think that JRBeanCollectionDataSource begins countting the Collection object from 1 and not from 0.

Thanks for your attention
 
 View user's profile Send private message  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT - 6 Hours
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2004 The PNphpBB Group
Credits