Jump to content
JasperReports Library 7.0 is now available ×

Subreport doesn't seem


2005 IR Help

Recommended Posts

By: primarykey - primarykey

Subreport doesn't seem

2004-07-18 11:43

I have a report and subreport inside it.But the subreport doesn't seem although

report seems properly. My report's subreport xml part is:

 

.

.

<parameter name="reportDirectory" class="java.io.File"/>

<field name="Foo" class="java.lang.Object">

<fieldDescription>Foo</fieldDescription>

</field>

<detail>

.

.

.

<band height="150" isSplitAllowed="true">

<subreport isUsingCache="true">

<reportElement mode="Opaque" x="30" y="5" width="670" height="20" forecolor="#000000" backcolor="#99CCFF" key="element-10" positionType="Float" isPrintRepeatedValues="true" isRemoveLineWhenBlank="true" isPrintInFirstWholeBand="false" isPrintWhenDetailOverflows="false"/>

<subreportParameter name="Foo">

<subreportParameterExpression><![CDATA[$F{Foo}]]></subreportParameterExpression>

</subreportParameter>

<dataSourceExpression>

$F{Foo}

</dataSourceExpression>

<subreportExpression class="java.lang.String">$P{reportDirectory}.getCanonicalPath() + java.io.File.separator + "FooReport.jasper"

</subreportExpression>

.

.

.

 

</band>

</detail>

 

My subreport is :

 

<?xml version="1.0" encoding="UTF-8"?>

 

<jasperReport name="FooReport" columnCount="1" printOrder="Vertical" orientation="Portrait" pageWidth="670" pageHeight="842" columnWidth="535" columnSpacing="0" leftMargin="30" rightMargin="30" topMargin="20" bottomMargin="20" whenNoDataType="AllSectionsNoDetail" isTitleNewPage="false" isSummaryNewPage="false">

<parameter name="Foo" isForPrompting="true" class="java.lang.Object"/>

<field name="asd" class="java.lang.Short"/>

<field name="xyz" class="java.lang.String"/>

<group name="TranskriptBilgileriGroup" isStartNewColumn="true" isStartNewPage="true" isResetPageNumber="false" isReprintHeaderOnEachPage="false" minHeightToStartNewPage="0">

<groupHeader>

<band height="50" isSplitAllowed="true">

<textField>

<reportElement mode="Opaque" x="2" y="2" width="70" height="18" forecolor="#000000" backcolor="#FFFFFF" positionType="FixRelativeToTop" isPrintRepeatedValues="true" isRemoveLineWhenBlank="false" isPrintInFirstWholeBand="false" isPrintWhenDetailOverflows="false"/>

<textElement textAlignment="Center" verticalAlignment="Top" lineSpacing="Single">

<font fontName="Serif" pdfFontName="Times-Roman" size="11" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded="false" pdfEncoding="CP1254" isStrikeThrough="false"/>

</textElement>

<textFieldExpression class="java.lang.Short"><![CDATA[$F{asd} + " / "]]></textFieldExpression>

</textField>

 

<textField>

<reportElement mode="Opaque" x="73" y="2" width="100" height="18" forecolor="#000000" backcolor="#FFFFFF" positionType="FixRelativeToTop" isPrintRepeatedValues="true" isRemoveLineWhenBlank="false" isPrintInFirstWholeBand="false" isPrintWhenDetailOverflows="false"/>

<textElement textAlignment="Left" verticalAlignment="Top" lineSpacing="Single">

<font fontName="Serif" pdfFontName="Times-Roman" size="11" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded="false" pdfEncoding="CP1254" isStrikeThrough="false"/>

</textElement>

<textFieldExpression class="java.lang.String"><![CDATA[$F{xyz}]]></textFieldExpression>

</textField>

</band>

</groupHeader>

 

</jasperReport>

 

 

My datasource includes a collection named Foo and I want this collection to iterate and write the values of collection in subreport. My DataSource is:

 

public class DataSourceBarFoo extends JRBeanCollectionDataSource {

 

private Object[] obj;

private int index = -1;

 

/**

* @param beanCollection

*/

public DataSourceTranskript(Collection beanCollection) {

super(beanCollection);

obj=beanCollection.toArray();

}

 

public boolean next() throws JRException {

index++;

return (index < obj.length);

}

 

public Object getFieldValue(JRField field) throws JRException {

Object value = null;

String fieldName = field.getName();

AbcDTO dto = (AbcDTO)obj[index];

 

if ("bar".equals(fieldName)) // Doesn't matter

// only an attribute for main report

value = new Short(dto.getBar());

else if("foo".equals(fieldName))

value=(Object)dto.getFoo();

return value;

}

}

 

It is urgent for me. Thanks for your help.

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...