gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 02:56:47 27 4
gpt4 key购买 nike

我正在将图像列表传递到我的报告中。我想在报告中的 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/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com