[英]JasperReports: How to call a java bean method in report template?
I am passing a java bean collection into a jasper report.我将 java bean 集合传递到碧玉报告中。 I have several fields for this java bean defined an they are display just fine in my report.
我为这个 java bean 定义了几个字段,它们在我的报告中显示得很好。
Im wondering if there is a way to call a method of a java bean that is being passed into this report???我想知道是否有一种方法可以调用正在传递到此报告中的 java bean 的方法???
Eg an expression for a text field, something like....例如,文本字段的表达式,例如....
{current java bean}.methodToCall()
Using the keyword _THIS
in a field name or description will make it map to the bean class itself.在字段名称或描述中使用关键字
_THIS
将使 map 成为 bean class 本身。 Using the fieldDescription tag is better as it allows you to do this with multiple beans.使用 fieldDescription 标记会更好,因为它允许您对多个 bean 执行此操作。
For example:例如:
<field name="customBean" class="com.example.customBean">
<fieldDescription>_THIS</fieldDescription>
</field>
Then you can call methods in an expression like this:然后你可以在这样的表达式中调用方法:
<textFieldExpression>$F{customBean}.someMethod()</textFieldExpression>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.