Note that there are some explanatory texts on larger screens.

plurals
  1. POLocating Resource Bundle Property in Jasper Reports
    text
    copied!<p>I have written small java program to get practice with <strong>Jasper Reports</strong>.</p> <p><em>Below is my java program which will generate report and export to PDF.</em></p> <pre><code>public class BaseReporter { public static void main(String[] args) { try { InputStream inputStream = BaseReporter.class.getResourceAsStream("/reports/helloworld.jasper"); DataBeanMaker dataBeanMaker = new DataBeanMaker(); ArrayList&lt;DataBean&gt; dataBeanList = dataBeanMaker.addDataBean(); JRBeanCollectionDataSource JRbeancollectiondatasource = new JRBeanCollectionDataSource(dataBeanList); Map&lt;String, Object&gt; parameters = new HashMap&lt;String, Object&gt;(); parameters.put("Created By", "xxx"); parameters.put("StylePath", "d:/Learn-WS/Jasper/src/reports/jr.jrtx"); // Export to PDF JasperPrint jasperPrint = JasperFillManager.fillReport(inputStream, parameters, JRbeancollectiondatasource); JasperExportManager.exportReportToPdfFile(jasperPrint, "d:/Learn-WS/Jasper/src/reports/helloworld.pdf"); System.out.println("report process completed ...."); } catch(Exception e) { System.out.println(e.getMessage()); } } } </code></pre> <p>And my package structure is</p> <pre><code>project src com BaseReport.java DataBean.java DataBeanMaker.java reports helloworld.jasper helloworld.jrxml jr.jrtx jr.properties </code></pre> <p>In the <strong>jr.properties</strong> file, i have added the property to be used in the report. report.name="Testing Report"</p> <p>I have included my resource bundle name in helloworld.jrxml file in the jasperReport tag with the attribute named <strong>resourceBundle="jr"</strong>.</p> <p>I have called the resource bundle property in report as</p> <pre><code>&lt;title&gt; &lt;band height="30"&gt; &lt;staticText&gt; &lt;reportElement uuid="6fbe7eb7-04cd-4c03-bc6e-b2cda3026d3b" mode="Opaque" x="0" y="3" width="535" height="23"/&gt; &lt;textElement textAlignment="Center"&gt; &lt;font size="14" isBold="true"/&gt; &lt;/textElement&gt; &lt;text&gt;&lt;![CDATA[$R{report.name}]]&gt;&lt;/text&gt; &lt;/staticText&gt; &lt;/band&gt; &lt;/title&gt; </code></pre> <p><strong>But the resource bundle property is not loaded / located properly in the report.</strong></p> <p>Kindly help me and thanks in advance.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload