java - JRBeanCollectionDatasource prints only first bean's propery values -


i'm working on simple jrbeancollection example, trying print property values of javabean collection pdf report.

the problem code prints of first bean of list create.

here code have written,

public static void main(string[] args) {     string filename = "src/test/report2.jasper";     string outfilename = "test.pdf";     hashmap hm = new hashmap();     jrbeancollectiondatasource beancollectiondatasource = new jrbeancollectiondatasource(fundbeanfactory.createbeancollection());     try {         jasperprint print = jasperfillmanager.fillreport(                 filename,                 hm,                 beancollectiondatasource);          jrpdfexporter exporter = new jrpdfexporter();          exporter.setexporterinput(new simpleexporterinput(print));         exporter.setexporteroutput(new simpleoutputstreamexporteroutput(outfilename));         simplepdfexporterconfiguration configuration = new simplepdfexporterconfiguration();         configuration.setcreatingbatchmodebookmarks(true);         exporter.setconfiguration(configuration);         exporter.exportreport();     } catch (jrexception e) {         e.printstacktrace();     } } 

the bean class,

public class fundbean {    private double debit;   private double credit;    public double getcredit() {       return credit;   }    public void setcredit(double credit) {       this.credit = credit;   }    public double getdebit() {       return debit;   }    public void setdebit(double debit) {       this.debit = debit;   } } 

the beanfactory class creates list,

public class fundbeanfactory {    public static list<fundbean> createbeancollection(){     list<fundbean> fundbeans   = new arraylist<fundbean>();      fundbean bean1 = new fundbean();     bean1.setcredit(89201.12);     bean1.setdebit(122392.23);      fundbean bean2 = new fundbean();     bean2.setcredit(95650.16);     bean2.setdebit(787878.80);     fundbeans.add(bean1);     fundbeans.add(bean2);      return fundbeans;   }  } 

the jrxml file:

<parameter name="credit" class="java.lang.double"/> <field name="debit" class="java.lang.double"/> <field name="credit" class="java.lang.double"/> <background>     <band splittype="stretch"/> </background> <title>     <band height="79" splittype="stretch">         <statictext>             <reportelement mode="opaque" x="61" y="17" width="420" height="43" backcolor="#999999" uuid="6878b8e7-ffdc-4465-842f-c1b6de0b5d87"/>             <textelement>                 <font size="24"/>             </textelement>             <text><![cdata[              available funds test]]></text>         </statictext>     </band> </title> <pageheader>     <band height="35" splittype="stretch"/> </pageheader> <columnheader>     <band height="151" splittype="stretch">         <statictext>             <reportelement mode="opaque" x="0" y="0" width="100" height="41" backcolor="#0033cc" uuid="2fca55e7-bfc3-4795-9735-5f4ca5b621e6"/>             <textelement>                 <font size="24"/>             </textelement>             <text><![cdata[debits]]></text>         </statictext>         <statictext>             <reportelement mode="opaque" x="100" y="0" width="100" height="41" backcolor="#0066cc" uuid="25536a17-ca40-4256-bc82-fca3b79be2ab"/>             <textelement>                 <font size="24"/>             </textelement>             <text><![cdata[credits]]></text>         </statictext>         <textfield>             <reportelement x="0" y="41" width="100" height="67" uuid="56004fd8-48e8-4cfe-9ecc-53324b94f8a2"/>             <textfieldexpression><![cdata[$f{debit}]]></textfieldexpression>         </textfield>         <textfield>             <reportelement x="100" y="41" width="100" height="67" uuid="ba4e4ab6-4a0f-4486-b2e6-15ffc0d04808"/>             <textfieldexpression><![cdata[$f{credit}]]></textfieldexpression>         </textfield>     </band> </columnheader> 

bean2 credit , debit values not printed, why happening?

to output report rows need put fields in detail band of report. have used column header band is, naturally, printed once.


Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -