栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

如何获得复杂的JavaBean的价值

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

如何获得复杂的JavaBean的价值

例如,您有一对JavaBean(POJO):

public class Order {    private double price;    private int quantity;    private Product product;    // public getters }public class Product {    private String name;    // public getters }

并且您以这种方式声明报告的数据源:(是的,我喜欢 Guava

JRBeanCollectionDataSource datasource = new JRBeanCollectionDataSource(Lists.newArrayList(ImmutableList.<Order>builder()        .add(new Order(1000.2, 10, new Product("Phone")))        .add(new Order(10200.0, 2, new Product("Tv")))        .build()));

如果使用此字段声明:

<field name="order" >    <fieldDescription><![CDATA[_THIS]]></fieldDescription></field><field name="price" /><field name="quantity" /><field name="productName" >    <fieldDescription><![CDATA[product.name]]></fieldDescription></field>

您可以使用以下表达式:

<textField>    <reportElement x="0" y="0" width="100" height="30"/>    <textFieldexpression><![CDATA[$F{price}]]></textFieldexpression></textField><textField>    <reportElement x="100" y="0" width="100" height="30"/>    <textFieldexpression><![CDATA[$F{quantity}]]></textFieldexpression></textField><textField>    <reportElement x="200" y="0" width="100" height="30"/>    <textFieldexpression><![CDATA[$F{productName}]]></textFieldexpression></textField>

注意:

  • 不要忘记吸气剂应该是公开的
  • 更多信息:JavaBean数据源


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/506346.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号