1 30 31 package it.businesslogic.ireport.examples; 32 33 import net.sf.jasperreports.engine.*; 34 import net.sf.jasperreports.engine.data.*; 35 import it.businesslogic.ireport.examples.beans.*; 36 import java.util.*; 37 38 public class PersonBeansDataSource extends JRAbstractBeanDataSourceProvider { 39 40 public PersonBeansDataSource() { 41 super(PersonBean.class); 42 43 } 44 45 public JRField[] getFields(JasperReport report) throws JRException 46 { 47 48 if (report != null) 49 { 50 System.out.println(report); 51 JRParameter[] params = report.getParameters(); 52 for (int i=0; i<params.length; ++i) 53 { 54 System.out.println(params[i].getName()+" "+params[i].getDefaultValueExpression()); 55 } 56 57 String [] properties = report.getPropertyNames(); 58 for (int i=0; i<properties.length; ++i) 59 { 60 System.out.println(properties[i] + " = " + report.getProperty(properties[i])); 61 } 62 } 63 return super.getFields(report); 64 } 65 66 67 68 public JRDataSource create(JasperReport report) throws JRException { 69 70 ArrayList list = new ArrayList(); 71 list.add(new PersonBean("Aldo")); 72 list.add(new PersonBean("Giovanni")); 73 list.add(new PersonBean("Giacomo")); 74 75 return new JRBeanCollectionDataSource(list); 76 77 } 78 79 public void dispose(JRDataSource dataSource) throws JRException { 80 } 82 } 83 | Popular Tags |