Facing problem with Pojo Datasource in 4.3 [message #1146711] |
Sun, 20 October 2013 10:43 |
|
I have observed a strange behavior with pojo datasource in 4.3. The following are my java files.
dataset class that i am using for data source:-
public class StudentRegDataSet {
private Iterator<StudentRegistrationDto> iterator;
public List<StudentRegistrationDto> getStudentRegs(){
List<StudentRegistrationDto> studRegs=new ArrayList<StudentRegistrationDto>();
StudentRegistrationDto studReg=null;
try{
studReg=new StudentRegistrationDto();
PreviousEducationDetailsDto previousEduDetails=new PreviousEducationDetailsDto();
List<SubjectDto>courseSubjects=new ArrayList<SubjectDto>();
SubjectDto sub1=new SubjectDto();
sub1.setSubjectName("English");
sub1.setMarks(60);
courseSubjects.add(sub1);
SubjectDto sub2=new SubjectDto();
sub2.setSubjectName("Science");
sub2.setMarks(80);
courseSubjects.add(sub2);
previousEduDetails.setCourseSubjects(courseSubjects);
studReg.setPreviousEduDetails(previousEduDetails);
List<DocumentDto> documents=new ArrayList<DocumentDto>();
DocumentDto doc1=new DocumentDto();
doc1.setDocName("Inter Certficate");
documents.add(doc1);
DocumentDto doc2=new DocumentDto();
doc2.setDocName("10th Certficate");
documents.add(doc2);
studReg.setDocuments(documents);
}catch(Exception e){
}
studRegs.add(studReg);
return studRegs;
}
@SuppressWarnings(value = { "unchecked" })
public void open(Object obj, Map<String,Object> map) {
iterator = getStudentRegs().iterator();
}
public Object next() {
if (iterator.hasNext())
return iterator.next();
return null;
}
public void close() { }
}
All the dto's i used are normal beans which have properties and setter/getter pairs. Not doing anything else with them. In the report when i create a Pojo Datasource i am mapping this class for the data source.
And when i created the data set in the report i have added "SubjectName" and "Marks" directly. Then the values are mapped to the data elements in my report. So everything went fine. The values of the properties of SubjectDto are shown in the report for "english" and "science". Everything went fine. But when i add "DocName" to the dataset of the report the entire report goes blank and when i check the log in the server "getStudentRegs()" isbeing called for 6-7 times and finally the report goes blank. If i remove the "DocName" from the dataset of the report everything works fine.
As i have to list the "DocName" in my report to get around this problem i have created another dataset for the same report and added "docName" to it and now i mapped it with the data element in my report. Now everything works fine. But problem with this approach is "getStudentRegs()" is being called twice. The entire "List<StudentRegistrationDto>" is being build twice which could be the major performance hit.
So is there any way that i can build my entire report just with one dataset in the report assuming that more number of data sets will have multiple calls to "getStudentRegs()" which i want to avoid.
Kindly help me in this. Thanks in advance.
Thanks and Regards,
Muralidhar Yaragalla.
http://yaragalla.blogspot.in
|
|
|
|
|
|
|
Re: Facing problem with Pojo Datasource in 4.3 [message #1182998 is a reply to message #1173697] |
Tue, 12 November 2013 15:19 |
|
It would appear that the problem you're having with the report not working is that when you return docName, it returns a list of docs and the POJO is trying to create a single row with an arrayList. When I run your report, I get an error that says something about 1 to n, so I'm assuming this is the cause for this error.
Michael
Developer Evangelist, Silanis
|
|
|
|
Re: Facing problem with Pojo Datasource in 4.3 [message #1183023 is a reply to message #1183007] |
Tue, 12 November 2013 15:34 |
|
Ah. I hadn't made it that far through the code, yet. Try working with just the documents list and not the subjects and see if it works only using one list, no matter which one. If it works with just the docs being used, please file a bug and post the bug info in here. Thanks.
Michael
Developer Evangelist, Silanis
|
|
|
|
Powered by
FUDForum. Page generated in 0.04197 seconds