• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2242
  • Last Modified:

Crystal reports XI java how to pass many pojo objects from jsp to CR issue.

I'm using Crystal Report XI for Java, and in my sample I'm using one Pojo dataset and it works ok, but I would like to know how to pass more than one pojo object to a same report result. ( like having two simple separate tables.)
This is a little peace of code inside the JSP:

String reportName = "submitedContracts.rpt";
ReportClientDocument clientDoc = (ReportClientDocument) session.getAttribute(reportName);
       clientDoc.open(reportName, OpenReportOptions._openAsReadOnly);
 // Populate POJO data source
 String className = "org.tempuri.FDCInformation.FDCInformationSrv.SubmittedContractsBE";
 List dataset = new ArrayList();
 dataset = (List)request.getAttribute("dataSet");
 JRCHelperSample.passPOJO(clientDoc, dataset, className, tableAlias, "");

IReportSource reportSource = clientDoc.getReportSource();
JRCHelperSample.exportPDF(reportSource, request, response, config.getServletContext(), true);

above example just send one Object to crystal report . Do you know how to send more than one object on above code example..? passPOJO just accept one object and I tried to below line after fill my second data set:
 JRCHelperSample.passPOJO(clientDoc, dataset2, className2, tableAlias2, ""); but does not work,

passPOJO method:

public static void passPOJO(ReportClientDocument clientDoc, Collection dataSet,
                  String className, String tableName, String reportName) throws ReportSDKException,ClassNotFoundException{
                  clientDoc.getDatabaseController().setDataSource(dataSet, Class.forName(className),tableName,tableName+"_POJO");
                  clientDoc.getSubreportController().getSubreport(reportName).getDatabaseController().setDataSource(dataSet, Class.forName(className),tableName,tableName+"_POJO");

Thank's in advance.
  • 2
1 Solution
Crystal can only work with a single data source unless you use subreports.

To use multiple tables simply create a dataset by joining the tables and passing the joined dataset to the report

Select T1.name, T2.Address
FROM T1 Inner join T2 on T1.Id = T2.id

rsamayoabAuthor Commented:
May I can pass a Map object that contain multiple sub objects and manipulate inside Crystal Reports , do you know if it is posible? . I tried with sub report and it work ok but I would like to have two bean objects
to be treated as tables and show this two objects in the same report. My report will have one grid to show information (dataset1 ) and a chart  (dataset1 ). I do not need more than one datasource, just one datasource with multiple datasets objects.

thank's in advance.
Crystal wants a single dataset for the report.  TO use multiple datasets you need to join them or use subreports.

In this case youwill need 2 subreports.

Forced accept.

EE Admin

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now