Custom Reports: Where do the Parameters Come From

Started by yellek, January 09, 2025, 02:50:31 AM

Previous topic - Next topic

yellek

In the Customisable Report JRXML file there are the lines:

<parameter name="properties_report" class="net.sf.jasperreports.engine.JasperReport"/>
<subreportExpression><![CDATA[$P{properties_report}]]></subreportExpression>


I am assuming that Archi passes that value so that the main report can access the subreport.

What if I want to do my own custom report using subreports? How do I specify the path to my subreport?

It appears as if the parameters are hard coded.

Phil Beauvoir

#1
Any properties passed by Archi can be found in the source code here:

https://github.com/archimatetool/archi/blob/master/com.archimatetool.jasperreports/src/com/archimatetool/jasperreports/JasperReportsExporter.java

There are some properties that can be set by the customizable report. These are documented in the "Customisable Report" section of the Archi User Guide.

Others will be Jasper internal properties or those declared in the *.jrxml files.
If you value and use Archi, please consider making a donation.
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

yellek

Is the answer to the rest of the question "dig around in the code and figure it out"? If so that shouldn't be a problem.

From my testing and what I can see the only sub reports that are compiled and available from Archi are ones named the same as those for the Customisable Report and passed into the main report by Archi. If I'm NOT using the Customisable Report my workaround is to define sub reports with the same names as the Customisable Report (properties.jrxml for example) and use those (this seems to work).

If I put my own sub reports with my custom report, Archi throws an error saying it can't find them.

yellek

Quote from: yellek on January 13, 2025, 22:33:01 PMFrom my testing and what I can see the only sub reports that are compiled and available from Archi are ones named the same as those for the Customisable Report and passed into the main report by Archi. If I'm NOT using the Customisable Report my workaround is to define sub reports with the same names as the Customisable Report (properties.jrxml for example) and use those (this seems to work).

If I put my own sub reports with my custom report, Archi throws an error saying it can't find them.

OK I figured it out and I'm leaving this here to guide others in the future:

The way that Archi compiles and processes Jasper sub reports is to pass compiled sub reports as a parameter to the main report. You can expect (and should declare) a parameter with a key that is the same as the name attribute of your sub report like the following:

<parameter name="properties_report" class="net.sf.jasperreports.engine.JasperReport"/>

You then call the sub report with an expression of the form:

<subreportExpression><![CDATA[$P{properties_report}]]></subreportExpression>

Which uses the compiled report passed in as a parameter.