views:

610

answers:

1

Hi, I want to create pdf document using JRDataSource using jasper report.Actually i m having one bean object that object has List of another bean object and one string value,The inner bean object has two String variables .Now i don't know how to map these all three variable in the jrxml document to populate the values in pdf document . Can anyone help me how to solve this problem.If u can provide me some code snippet.

+1  A: 

Code snippet to create a JasperPrint object from a collection datasource.

JasperPrint jp = new JasperPrint();
String reportPath = "/HD/jasper/mypath/myfile.jasper";

Map paramsMap = new HashMap();  //put whatever parameters you want to pass to report

//JR data source, populate with your collection
JRDataSource reportSource = new JRBeanCollectionDataSource( reportCollection );

jp = JasperFillManager.fillReport( reportPath, paramsMap, reportSource);

//Here you can use the PDF generator to make a PDF file out of the jp object. Then forward it to client
medopal