java - JasperReports Connection -


i'm trying export datatable, i'm using jasperreport, doesn't work. got error:

net.sf.jasperreports.engine.jrexception: error retrieving field value bean 

can me please.

  <?xml version="1.0" encoding="utf-8"?>   <jasperreport xmlns="http://jasperreports.sourceforge.net/jasperreports"            xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"                xsi:schemalocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd"            name="null" language="groovy" pagewidth="842" pageheight="595" orientation="landscape" columnwidth="802"            leftmargin="20" rightmargin="20" topmargin="20" bottommargin="20" > <style name="title" fontname="times new roman" fontsize="50" isbold="true" pdffontname="times-bold"/> <style name="subtitle" forecolor="#736343" fontname="arial" fontsize="18"/> <style name="column header" forecolor="#666666" fontname="arial" fontsize="12" isbold="true"/> <style name="detail" fontname="arial" fontsize="12"/> <style name="row" mode="transparent">     <conditionalstyle>         <conditionexpression><![cdata[$v{report_count}%2 == 0]]></conditionexpression>         <style backcolor="#e6dac3"/>     </conditionalstyle> </style> <querystring language="hql">     <![cdata[select  article.`code_article` article_code_article,  article.`designational` article_designational,  article.`designationfr` article_designationfr  `article` article]]> </querystring> <field name="article_code_article" class="java.lang.string"/> <field name="article_designational" class="java.lang.string"/> <field name="article_designationfr" class="java.lang.string"/> <background>     <band splittype="stretch"/> </background> <title>     <band height="136" splittype="stretch">          <statictext>             <reportelement style="title" x="270" y="0" width="263" height="62"/>             <textelement verticalalignment="middle">                 <font pdffontname="times-roman"/>             </textelement>             <text><![cdata[articles]]></text>         </statictext>        </band> </title> <pageheader>     <band splittype="stretch"/> </pageheader> <columnheader>     <band height="16" splittype="stretch">         <line>             <reportelement positiontype="fixrelativetobottom" x="0" y="15" width="802" height="1" />             <graphicelement>                 <pen linewidth="0.5" linecolor="#999999"/>             </graphicelement>         </line>         <statictext>             <reportelement style="column header" x="0" y="0" width="267" height="15" forecolor="#736343" />             <text><![cdata[article_code_article]]></text>         </statictext>         <statictext>             <reportelement style="column header" x="267" y="0" width="267" height="15" forecolor="#736343" />             <text><![cdata[article_designational]]></text>         </statictext>         <statictext>             <reportelement style="column header" x="534" y="0" width="267" height="15" forecolor="#736343" />             <text><![cdata[article_designationfr]]></text>         </statictext>     </band> </columnheader> <detail>     <band height="15" splittype="stretch">         <frame>             <reportelement style="row" mode="opaque" x="0" y="0" width="802" height="15"/>             <textfield isstretchwithoverflow="true">                 <reportelement style="detail" x="0" y="0" width="267" height="15"/>                 <textfieldexpression><![cdata[$f{article_code_article}]]></textfieldexpression>             </textfield>             <textfield isstretchwithoverflow="true">                 <reportelement style="detail" x="267" y="0" width="267" height="15"/>                 <textfieldexpression><![cdata[$f{article_designational}]]></textfieldexpression>             </textfield>             <textfield isstretchwithoverflow="true">                 <reportelement style="detail" x="534" y="0" width="267" height="15"/>                 <textfieldexpression><![cdata[$f{article_designationfr}]]></textfieldexpression>             </textfield>         </frame>     </band> </detail> <columnfooter>     <band height="6" splittype="stretch">         <line>             <reportelement positiontype="fixrelativetobottom" x="0" y="3" width="802" height="1" />             <graphicelement>                 <pen linewidth="0.5" linecolor="#999999"/>             </graphicelement>         </line>     </band> </columnfooter> <pagefooter>     <band height="25" splittype="stretch">         <frame>             <reportelement mode="opaque" x="-21" y="1" width="843" height="24" forecolor="#d0b48e" backcolor="#f2ebdf" />             <textfield evaluationtime="report">                 <reportelement style="column header" x="783" y="1" width="40" height="20" forecolor="#736343" />                 <textelement verticalalignment="middle">                     <font size="10" isbold="false"/>                 </textelement>                 <textfieldexpression><![cdata[" " + $v{page_number}]]></textfieldexpression>             </textfield>             <textfield>                 <reportelement style="column header" x="703" y="1" width="80" height="20" forecolor="#736343" />                 <textelement textalignment="right" verticalalignment="middle">                     <font size="10" isbold="false"/>                 </textelement>                 <textfieldexpression><![cdata["page "+$v{page_number}+" of"]]></textfieldexpression>             </textfield>             <textfield pattern="eeeee dd mmmmm yyyy">                 <reportelement style="column header" x="22" y="1" width="197" height="20" forecolor="#736343"/>                 <textelement verticalalignment="middle">                     <font size="10" isbold="false"/>                 </textelement>                 <textfieldexpression><![cdata[new java.util.date()]]></textfieldexpression>             </textfield>         </frame>     </band> </pagefooter> <summary>     <band splittype="stretch"/> </summary> 

and function:

 public void test(){       jasperreport jasperreport; jasperprint jasperprint; try {   jasperreport = jaspercompilemanager.compilereport(       "c:/soprocess/exportmodel/report1.jrxml");         jrbeancollectiondatasource beancoldatasource =   new jrbeancollectiondatasource(articledao.findall());   jasperprint = jasperfillmanager.fillreport(       jasperreport, new hashmap(),beancoldatasource);   jasperexportmanager.exportreporttopdffile(       jasperprint, "c:/soprocess/exportmodel/simple_report.pdf"); } catch (jrexception e) {   e.printstacktrace(); } 

the

net.sf.jasperreports.engine.jrexception: error retrieving field value bean 

is thrown when jasper report can't access public getter name of field in bean passing datasource.

you need have in bean passed articledao.findall() method's similar to

public string getarticle_code_article(){//your code} public string getarticle_designational(){//your code} public string getarticle_designationfr(){//your code} 

since have these fields

<field name="article_code_article" class="java.lang.string"/> <field name="article_designational" class="java.lang.string"/> <field name="article_designationfr" class="java.lang.string"/> 

note that:

<querystring language="hql"> <![cdata[select article.`code_article` article_code_article, article.`designational` article_designational, article.`designationfr` article_designationfr  `article` article]]> </querystring> 

is not considered since passing jrbeancollectiondatasource, if considered need pass hibernate connection instead (along other configurations jasper report understand mapping) .


Comments

Popular posts from this blog

r - how do you merge two data frames the best way? -

How to debug "expected android.widget.TextView but found java.lang.string" in Android? -

php - mySQL problems with this code? -