I would like to pass as a parameter to my .jrxml an arbitrary object of my domain, e.g a Person.
InputStream reportFile = MyPage.this.getClass().getResource
Yes, it is possible exactly the way you explained. Just make sure you have the correct classpath when compiling the jrxml and be careful with the case - either lowercase (person
) or uppercase (PERSON
) in all places.
Yes, you can pass any Java object, but you should make sure to import that object in the JRXML.
Inside the jasperReport tag. You can use the tag import
, like:
<jasperReport...>
<import value="org.justfortest.Person">
However, you can use JRBeanCollectionDataSource
and populate the report with a list of your object, without needing to store arbitrary objects in the params map.
Check this tutorial for more info on Jasper Reports Bean Collection Data Source