Referencing a Bean in JasperReports

Posted on Sat 10 September 2016 in General Software Development

Thanks to this answer on StackOverflow, I know how easy it is to reference the bean itself instead of one of its properties in a text field expression in JasperReports. The trick is to declare a field whose description is set to the keyword _THIS:

<field name="myBean" class="de.uwesander.MyBean">

Then it can be referenced in the text field expression as follows:

    <![CDATA[$F{myBean} instanceof ...]]>