Software Technology Tips

With the recent release of JasperReport Plug-in, Now, you can directly add any fields, calculations(stored/un-stored), aggregations, global variables, related fields and many more, to your Jasper Report, as you are doing in  Servoy itself. You don't have write huge SQL Query for the same. Just pass your foundset to the report and access the fields, related fields from the JasperReport basing on the passed foundset. In this TIP, we will  know how we can add a Sub-Report to the Jasper Report and pass a Servoy Foundset to the SubReport.

To add a Sub-Report to your JasperReport at design time with IReport (IReport is the popular Jasper Report Designer tool), you can drag the Sub-Report element from the Element pallet of IReport, to the JasperReport. This will generate the below XML for you.


<reportElement x="167" y="31" width="200" height="100"/>




<subreportExpression class="java.lang.String">

<![CDATA[$P{SUBREPORT_DIR} + "Report-Sub.jasper"]]>



Where, “Report-Sub.jasper” is your Sub-Report which is going to be added to your JasperReport. To pass a Servoy Foundset to your Sub-Report, you need to specify a Data Source for the Sub-Report. Here, in the above Sub-Report XML, we are passing the Report Field, 'customers_to_orders' as the data source for the Sub-Report. We can specify a Report Parameter or a Report Field as Data Source for Sub-Report. But, one IMPORTANT thing that we need to take care of is that, the Parameter or Field MUST be of class “net.sf.jasperreports.engine.JRDataSource”.

<field name="costomers_to_orders" class="net.sf.jasperreports.engine.JRDataSource"/>


<parameter name="costomers_to_orders" class="net.sf.jasperreports.engine.JRDataSource" isForPrompting="false"/>


And from Servoy you can pass the Servoy Foundset to the Sub-Report, if you are using a Report Parameter as Sub-Report's Data Source or you need to specify the foundset according to the report Foundset if you are using Report Fields.

Related Tags:

Servoy, Jasper Report

Author: Arup Sahoo

Related Pages

  • Servoy Development Offshore
  • Servoy Development Projects


Let us Connect!

Awards and Achievements

Red Herringcolor DeloitteFast50 DB ZInnov1   Nascome  DB Stpi

This site uses cookies. We respect your privacy.copyright (c) Mindfire Solutions 2007-2015. Login