list - 如何在 JRBeanCollectionDataSource 上调用 *this*?

标签 list jasper-reports this

我正在将图像列表传递到我的报告中。我想在报告中的 List 对象中呈现它。

我以前使用过 JasperReports 列表,我知道我可以使用 $F{} 标记引用列表中元素的每个字段,但是我如何引用列出自己?

基本上我想使用像 $F{this}$F{self} 这样的东西。有这种事吗?

最佳答案

是的,您可以使用别名 _THIS

引自 JasperReports 终极指南:

A special field mapping can be used to access the current JavaBean object itself. Thus, when a field uses _THIS as description or name, the data source will return the current JavaBean object as field value. This is useful when the report needs to extract from the current object some data that does not correspond to a property that follows JavaBeans standards (for instance, the data is returned by a method that takes some arguments), or when the current object needs to be passed to as argument to a method called in one of the report expressions.

使用_THIS的示例

jrxml 文件的片段:

<subDataset name="dataset1">
    <field name="city" class="java.lang.String">
        <fieldDescription><![CDATA[_THIS]]></fieldDescription>
    </field>
</subDataset>

JavaBean的片段:

public class AddressBean {

    private String city;
    private Integer id;
    private PersonBean person;

    public AddressBean getAddress() {
        return this;
    }

    public String getCity() {
        return city;
    }

    public Integer getId() {
        return id;
    }

JasperReports 终极指南here .

您还可以阅读 GenericJonHow to access the root element of the datasource in jasperreports 上的回答问题。

关于list - 如何在 JRBeanCollectionDataSource 上调用 *this*?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16542732/

相关文章:

javascript - js ES6多态性中如何使用this和super

javascript - 如何使用此和(多个)动态括号表示法更改 vue 数据变量

python - 如何在嵌套列表中添加与另一个列表相对应的值?

python - 对 numpy 数组中存在的元组中的列进行切片

java - 检查来自另一个 java 类的登录系统的列表元素

java - Jasper report可以同时使用connection和bean吗?

javascript - 我们可以将JasperReports与AngularJS一起使用吗?

python - 在python中读取csv文件

java - 未在指定日期范围内获取 Jasper 报告

javascript - 在 JavaScript 事件处理程序中处理对象函数