无法在jasper中打印Arraylist中的客户详细信息

时间:2013-12-08 09:47:39

标签: java struts2 jasper-reports

我能够显示简单到jasper的报告,但无法显示arrayList值。 我有一个arrayList变量customerList。其中只包含一个客户详细信息,我想在jasper报告中显示其名称和地址。

如何做到这一点。 我的代码如下:

我正在采取行动类

public class SubmitBillAction extends ActionSupport {
    private float subTotal;
    private float vat;
    private float total;
    private ArrayList<SubmitBillAction> list;
    private ArrayList<CustomerAction> customerList;
  //getter and setter
}

在struts.xml中

 <action name="myJasperTest" class="iland.bill.SubmitBillAction" method="fetch">
            <result name="success" type="jasper">
                <param name="location">/pages/billing/billReport.jasper</param>
                <param name="dataSource">list</param>
                <param name="format">PDF</param>
            </result>
        </action>

在碧玉报告中

<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="null" pageWidth="595" pageHeight="842" columnWidth="535" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
    <property name="ireport.zoom" value="1.0"/>
    <property name="ireport.x" value="0"/>
    <property name="ireport.y" value="0"/>
    <field name="billNo" class="java.lang.Long"/>
    <field name="paymentType" class="java.lang.String"/>
    <field name="subTotal" class="java.lang.Float"/>
    <field name="vat" class="java.lang.Float"/>
    <field name="total" class="java.lang.Float"/>
    <field name="customerName" class="java.lang.String"/>
    <field name="address" class="java.lang.String"/>
    <field name="customerList" class="java.util.List"/>
    <background>
        <band/>
    </background>
    <title>
        <band height="72">
            <frame>
                <reportElement mode="Opaque" x="-20" y="-20" width="595" height="92" backcolor="#006699"/>
                <staticText>
                    <reportElement x="20" y="20" width="234" height="43" forecolor="#FFFFFF"/>
                    <textElement>
                        <font size="34" isBold="true"/>
                    </textElement>
                    <text><![CDATA[Timepass    ]]>
                    </text>
                </staticText>
                <staticText>
                    <reportElement x="395" y="54" width="180" height="20" forecolor="#FFFFFF"/>
                    <textElement textAlignment="Right">
                        <font size="14" isBold="false"/>
                    </textElement>
                    <text><![CDATA[This is very good desscription 


                    ]]>
                    </text>
                </staticText>
            </frame>
        </band>
    </title>
    <pageHeader>
        <band height="38">
            <staticText>
                <reportElement x="45" y="10" width="436" height="28"/>
                <textElement textAlignment="Center">
                    <font size="18" isBold="true" isUnderline="false"/>
                </textElement>
                <text><![CDATA[Bill Details ]]>
                </text>
            </staticText>
        </band>
    </pageHeader>
    <detail>
        <band height="173">
            <textField>
                <reportElement x="71" y="106" width="180" height="27"/>
                <textElement>
                    <font size="12" isBold="true" isUnderline="false"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{paymentType}]]>
                </textFieldExpression>
            </textField>
            <textField>
                <reportElement x="301" y="106" width="180" height="27"/>
                <textElement>
                    <font size="12" isBold="true" isUnderline="false"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{billNo}]]>
                </textFieldExpression>
            </textField>
            <staticText>
                <reportElement x="71" y="86" width="180" height="20"/>
                <textElement>
                    <font size="12" isBold="true" isUnderline="false"/>
                </textElement>
                <text><![CDATA[Payment Type  ]]>
                </text>
            </staticText>
            <staticText>
                <reportElement x="301" y="86" width="180" height="20"/>
                <textElement>
                    <font size="12" isBold="true" isUnderline="false"/>
                </textElement>
                <text><![CDATA[Bill No ]]>
                </text>
            </staticText>
        </band>
        <band height="93">
            <staticText>
                <reportElement x="45" y="12" width="87" height="20"/>
                <textElement textAlignment="Justified">
                    <font size="12" isBold="true" isUnderline="false"/>
                </textElement>
                <text><![CDATA[Sub Total ]]>
                </text>
            </staticText>
            <textField>
                <reportElement x="276" y="12" width="125" height="20"/>
                <textElement>
                    <font size="12" isBold="true"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{subTotal}]]>
                </textFieldExpression>
            </textField>
            <staticText>
                <reportElement x="45" y="40" width="87" height="20"/>
                <textElement textAlignment="Justified">
                    <font size="12" isBold="true" isUnderline="false"/>
                </textElement>
                <text><![CDATA[Vat  ]]>
                </text>
            </staticText>
            <textField>
                <reportElement x="276" y="41" width="125" height="19"/>
                <textElement>
                    <font size="12" isBold="true"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{vat}]]>
                </textFieldExpression>
            </textField>
            <staticText>
                <reportElement x="45" y="65" width="87" height="20"/>
                <textElement textAlignment="Justified">
                    <font size="12" isBold="true" isUnderline="false"/>
                </textElement>
                <text><![CDATA[Total  ]]>
                </text>
            </staticText>
            <textField>
                <reportElement x="276" y="70" width="125" height="23"/>
                <textElement>
                    <font size="12" isBold="true"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{total}]]>
                </textFieldExpression>
            </textField>
        </band>
    </detail>
    <columnFooter>
        <band/>
    </columnFooter>
    <pageFooter>
        <band height="17">
            <textField>
                <reportElement mode="Opaque" x="0" y="4" width="515" height="13" backcolor="#E6E6E6"/>
                <textElement textAlignment="Right"/>
                <textFieldExpression><![CDATA["Page "+$V{PAGE_NUMBER}+" of"]]>
                </textFieldExpression>
            </textField>
            <textField evaluationTime="Report">
                <reportElement mode="Opaque" x="515" y="4" width="40" height="13" backcolor="#E6E6E6"/>
                <textElement/>
                <textFieldExpression><![CDATA[" " + $V{PAGE_NUMBER}]]>
                </textFieldExpression>
            </textField>
            <textField pattern="EEEEE dd MMMMM yyyy">
                <reportElement x="0" y="4" width="100" height="13"/>
                <textElement/>
                <textFieldExpression><![CDATA[new java.util.Date()]]>
                </textFieldExpression>
            </textField>
        </band>
    </pageFooter>
    <summary>
        <band/>
    </summary>
</jasperReport>

我尝试使用 link

中的subDataSets解决此问题

0 个答案:

没有答案