-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: How to handle object array in Jasper Reports
PostPosted: Sun Oct 11, 2009 12:18 pm 
Newbie

Joined: Sun Oct 11, 2009 12:11 pm
Posts: 1
Hello All,

My Query returns two Objects

List query = session.createQuery("from Obj1, Obj2 <where clause>");

I have two objects Say: Object1 and Obectj2 (beans)

In JRXML

<field name = "field1" class = "java.lang.Integer">
<field name = "field2" class = "java.lang.Integer">

How to tell Jasper Reports that field1 belongs to the Object1 and field2 belongs to Object2.

Code:

Collection dataSource = new ArrayList();
dataSource.add(Obj1);
dataSource.add(Obj2);
JRBeanCollectionDataSource ds = new JRBeanCollectionDataSource(dataSource);

JasperReport jasperReport = JasperCompileManager.compileReport(new java.io.FileInputStream(new java.io.File("Reports/Report.xml")));
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters,ds);
JasperExportManager.exportReportToPdfStream(jasperPrint, new java.io.FileOutputStream(new java.io.File("Report.pdf")));
System.out.println("Report Generated");


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.