How to use Map<String, Object> parameter

Deal all 

 Recently started learning Jasper Report, I have some doubts about data filling.

Question 1

<em>Map<String, Object> parameter = new HashMap<>();
parameter.put("my_title", "Hi, I am title");
parameter.put("myBean", new MyBean());
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperDesign, parameter, new JREmptyDataSource());</em>

about this code ,

I created parameters named "my_title" and class = java.lang.String with Jaspersoft Studio ps: <textFieldExpression><![CDATA[$P{my_title}]]></textFieldExpression>

If I want to use javebean like jackson such as <textFieldExpression><![CDATA[$P{}]]></textFieldExpression>

What should I do ?'s picture
Joined: Apr 7 2023 - 9:13pm
Last seen: 4 months 2 weeks ago

1 Answer:

Make your bean a field not a parameter.

Instead of using new JREmptyDataSource(), you can use JRBeanCollectionDataSource.

olyncircle's picture
Joined: May 30 2022 - 5:42pm
Last seen: 2 months 3 weeks ago