我是JasperReports的新手。我做了一些简单的报告,但没有这么复杂。我已经搜索了论坛超过一天,我无法让这个工作。
我得到的错误:
从bean检索字段值时出错:eventPlanTimeSlotBeanDataSet
如果有人能帮我解决问题,我将非常感激。
提前致谢, 汤姆
我的豆子:
public class EventPlanTimeSlotBean {
private String timeSlot;
private List<OrganizerResultReportBean> orgResultBeans = new ArrayList<OrganizerResultReportBean>();
public EventPlanTimeSlotBean(String timeSlot, List<OrganizerResultReportBean> orgResultBeans) {
this.timeSlot = timeSlot;
this.orgResultBeans = orgResultBeans;
}
public String getTimeSlot() {
return timeSlot;
}
public void setTimeSlot(String timeSlot) {
this.timeSlot = timeSlot;
}
public List<OrganizerResultReportBean> getOrgResultBeans() {
return orgResultBeans;
}
public void setOrgResultBeans(List<OrganizerResultReportBean> orgResultBeans) {
this.orgResultBeans = orgResultBeans;
}
我的jrxml文件:
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="120"/>
<subDataset name="dataset1">
<field name="timeSlot" class="java.lang.String">
<fieldDescription><![CDATA[_THIS]]></fieldDescription>
</field>
</subDataset>
<parameter name="eventPlanNameParam" class="java.lang.String"/>
<parameter name="destinationNameColumnLabel" class="java.lang.String"/>
<parameter name="destinationCityColumnLabel" class="java.lang.String"/>
<parameter name="totalFlightCostsColumnLabel" class="java.lang.String"/>
<parameter name="timeSlotColumnLabel" class="java.lang.String"/>
<field name="eventPlanTimeSlotBeanDataSet" class="java.util.List"/>
<title>
<band height="110" splitType="Stretch">
<staticText>
<reportElement mode="Transparent" x="0" y="20" width="50" height="20" uuid="2af07c91-7b37-4c3a-8eea-53bfc065426e"/>
<text><![CDATA[Name:]]></text>
</staticText>
<textField isBlankWhenNull="true">
<reportElement mode="Transparent" x="60" y="20" width="300" height="20" uuid="2710e1b0-2493-409e-903b-381ddbb08392"/>
<textFieldExpression><![CDATA[$P{eventPlanNameParam}]]></textFieldExpression>
</textField>
</band>
</title>
<columnHeader>
<band height="30" splitType="Stretch">
<textField>
<reportElement mode="Transparent" x="0" y="5" width="100" height="20" uuid="d7a2f1cf-5325-4841-b46b-01c3c131d3ea"/>
<textFieldExpression><![CDATA[$P{timeSlotColumnLabel}]]></textFieldExpression>
</textField>
<textField>
<reportElement mode="Transparent" x="100" y="5" width="100" height="20" uuid="d7a2f1cf-5325-4841-b46b-01c3c131d3ea"/>
<textFieldExpression><![CDATA[$P{destinationNameColumnLabel}]]></textFieldExpression>
</textField>
<textField>
<reportElement mode="Transparent" x="200" y="5" width="100" height="20" uuid="cccc198b-10db-434d-b5c1-ddfcf0b3a0ab"/>
<textFieldExpression><![CDATA[$P{destinationCityColumnLabel}]]></textFieldExpression>
</textField>
<textField>
<reportElement mode="Transparent" x="300" y="5" width="100" height="20" uuid="cccc198b-10db-434d-b5c1-ddfcf0b3a0ab"/>
<textFieldExpression><![CDATA[$P{totalFlightCostsColumnLabel}]]></textFieldExpression>
</textField>
<line>
<reportElement mode="Opaque" x="0" y="24" width="511" height="1" uuid="ca213328-f473-4c93-a888-c1fd2181f0e4"/>
</line>
</band>
</columnHeader>
<detail>
<band height="25" splitType="Stretch">
<componentElement>
<reportElement x="100" y="0" width="400" height="20" uuid="320e66be-b719-4e1d-b1c8-9215179d7200"/>
<jr:list xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd" printOrder="Vertical">
<datasetRun subDataset="dataset1" uuid="056d45ca-4628-4bc5-bb1f-f44bb6d74c82">
<dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($F{eventPlanTimeSlotBeanDataSet})]]></dataSourceExpression>
</datasetRun>
<jr:listContents height="20" width="400">
<textField>
<reportElement x="0" y="0" width="100" height="20" uuid="db39f665-58b9-43ba-89dc-0d93e2f02a77"/>
<box leftPadding="10">
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textFieldExpression><![CDATA[$F{timeSlot}]]></textFieldExpression>
</textField>
</jr:listContents>
</jr:list>
</componentElement>
</band>
</detail>
填写报告:
try {
jasperPrint = JasperFillManager.fillReport(jreport, meetingResultMap,
new JRBeanCollectionDataSource(getDataSource(session, searchTask, eventPlan)));
} catch (JRException e) {
throw new LocalizedException("meeting_report_pdf_could_not_be_created" + ": " + e.getMessage());
}