How to pass parameters to query?

There are two syntax expressions for parameter referencing in JasperReports: $P{} and $P!{}. $P{paramName} syntax is using mostly for setting WHERE input parameters values. The replacement algorithm is “smart”, its implementation uses java.sql.PreparedStatement: for java.lang.String parameter the engine will replace $P{parameterName} with quoted value, for java.lang.Integer – with numeric value and so on. The sample: … Read more

JRBeanCollectionDataSource: How to show data from the java.util.List from JavaBean?

Here is the working sample. The key points of this sample: using of the _THIS expression; using List (jr:list) component in Detail band The snippet of code for generating report: public static void testBuildPdf() { try { Map<String, Object> params = new HashMap<String, Object>(); JasperReport jasperReport = JasperCompileManager.compileReport(reportSource); JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, params, getDataSource()); JasperExportManager.exportReportToPdfFile(jasperPrint, … Read more