teodanciu
-
Posts
4 -
Joined
-
Last visited
Content Type
Profiles
Forum
Events
Featured Visualizations
Knowledge Base
Documentation (PDF Downloads)
Blog
Documentation (Test Area)
Documentation
Dr. Jaspersoft Webinar Series
Downloads
Posts posted by teodanciu
-
-
Is the same valid for $P{REPORT_DATASOURCE} ? I am having the same problem...no data is displayed, only a horizontal line.
I defined a subdataset with corresponding fields, and trying to use this subdataset in a table (with <dataSourceExpression><![CDATA[$P{REPORT_DATA_SOURCE}]]></dataSourceExpression>)
Is it necessary to use the $P{REPORT_DATASOURCE} in the master before passing it to the table?
Thanks!
-
Hello,
I'm trying to generate a report with a table which contains fields from a JRBeanArrayDataSource.
However, I'm pretty stuck, because the table simply isn't displayed in the report (although no error is reported).
This is what I want to obtain:
Territory east west However, the report contains a simple horizontal line instead of the table.
I'm trying to use the jr:table as follows:
1) First, I'm using a JRBeanArrayDataSource constructed with the following array of objects:
public static Object[] createBeanCollection() {
Object[] reportRows= new Object[2];
reportRows[0] = new FilterData("east"); //public FilterData(String territory)
reportRows[1] = new FilterData("wast");
return reportRows;
}
where FilterData is a simple javabean, having a "territory" property.
1) In my jrxml, I declared a subdataset containing the territory field.
<subDataset name="Table Dataset 1">
<field name="territory" class="java.lang.String"/>
</subDataset>
( I am not sure if this approach is ok. Does declaring the field "territory" in the subDataset enable me to use $F{territory} in jr:detailCell? Because this is what I'm doing...and it doesn't work).
2) I'm trying to use this subDataset in a jr:table, as follows: (in the <detail> <band> section)
<jr:table xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/componentshttp://jasperreports.sourceforge.net/xsd/components.xsd">
<datasetRun subDataset="Table Dataset 1">
<dataSourceExpression><![CDATA[$P{REPORT_DATA_SOURCE}]]></dataSourceExpression>
</datasetRun>
<jr:column width="90">
<jr:columnHeader style="table_CH" height="30">
<staticText>
<reportElement x="0" y="0" width="90" height="30"/>
<text><![CDATA[Territory]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="table_TD" height="20">
<textField>
<reportElement x="0" y="0" width="90" height="20"/>
<textFieldExpression class="java.lang.String"><![CDATA[$F{territory}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
</jr:table>
Do you have any idea on what I' m doing wrong here?
Thanks a lot!
Teo
Code: public static Object[] createBeanCollection() { Object[] reportRows= new Object[2]; reportRows[0] = new FilterData("east"); //public FilterData(String territory) reportRows[1] = new FilterData("wast"); return reportRows; }<subDataset name="Table Dataset 1"> <field name="territory" class="java.lang.String"/></subDataset><jr:table xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd"> <datasetRun subDataset="Table Dataset 1"> <dataSourceExpression><![CDATA[$P{REPORT_DATA_SOURCE}]]></dataSourceExpression> </datasetRun> <jr:column width="90"> <jr:columnHeader style="table_CH" height="30"> <staticText> <reportElement x="0" y="0" width="90" height="30"/> <text><![CDATA[Territory]]></text> </staticText> </jr:columnHeader> <jr:detailCell style="table_TD" height="20"> <textField> <reportElement x="0" y="0" width="90" height="20"/> <textFieldExpression class="java.lang.String"><![CDATA[$F{territory}]]></textFieldExpression> </textField> </jr:detailCell> </jr:column></jr:table>
-
Hello,
I'm trying to generate a report with a table which contains data from the main data source.
However, I'm pretty stuck, because the table simply isn't displayed in the report (although no error is reported).
This is what I want to obtain:
Territory east west However, the report contains a simple horizontal line instead of the table.
I'm trying to use the jr:table as follows:
1) First, I'm using a JRBeanArrayDataSource constructed with the following array of objects:
public static Object[] createBeanCollection() {
Object[] reportRows= new Object[2];
reportRows[0] = new FilterData("east"); //public FilterData(String territory)
reportRows[1] = new FilterData("wast");
return reportRows;
}
where FilterData is a simple javabean, having a "territory" property.
1) In my jrxml, I declared a subdataset containing the territory field.
<subDataset name="Table Dataset 1">
<field name="territory" class="java.lang.String"/>
</subDataset>
( I am not sure if this approach is ok. Does declaring the field "territory" in the subDataset enable me to use $F{territory} in jr:detailCell? Because this is what I'm doing...and it doesn't work).
2) I'm trying to use this subDataset in a jr:table, as follows: (in the <detail> <band> section)
<jr:table xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd">
<datasetRun subDataset="Table Dataset 1">
<dataSourceExpression><![CDATA[$P{REPORT_DATA_SOURCE}]]></dataSourceExpression>
</datasetRun>
<jr:column width="90">
<jr:columnHeader style="table_CH" height="30">
<staticText>
<reportElement x="0" y="0" width="90" height="30"/>
<text><![CDATA[Territory]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="table_TD" height="20">
<textField>
<reportElement x="0" y="0" width="90" height="20"/>
<textFieldExpression class="java.lang.String"><![CDATA[$F{territory}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
</jr:table>
Do you have any idea on what I' m doing wrong here?
Thanks a lot!
Teo
Code: public static Object[] createBeanCollection() { Object[] reportRows= new Object[2]; reportRows[0] = new FilterData("east"); //public FilterData(String territory) reportRows[1] = new FilterData("wast"); return reportRows; }<subDataset name="Table Dataset 1"> <field name="territory" class="java.lang.String"/></subDataset><jr:table xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd"> <datasetRun subDataset="Table Dataset 1"> <dataSourceExpression><![CDATA[$P{REPORT_DATA_SOURCE}]]></dataSourceExpression> </datasetRun> <jr:column width="90"> <jr:columnHeader style="table_CH" height="30"> <staticText> <reportElement x="0" y="0" width="90" height="30"/> <text><![CDATA[Territory]]></text> </staticText> </jr:columnHeader> <jr:detailCell style="table_TD" height="20"> <textField> <reportElement x="0" y="0" width="90" height="20"/> <textFieldExpression class="java.lang.String"><![CDATA[$F{territory}]]></textFieldExpression> </textField> </jr:detailCell> </jr:column></jr:table>
jr:table using the REPORT_DATA_SOURCE datasource
in Products
Posted
Hi ,
It's been a while since then, but I recall:
1) wrapping the JRBeanArrayDataSource into a JRMapArrayDataSource, like this :
Map[] masterData = new Map[1];
masterData[0] = new HashMap();
masterData[0].put("filterDataSource", filterDataSource);
//I had other similar dataSources
and then created and passed the data source like this: new JRMapArrayDataSource(masterData)
2) The, in the jrxml file, I replaced the $P{REPORT_DATA_SOURCE} with $F{filterDataSource}. Something like this:
<subDataset name="filterDataSet">
<field name="territory" class="java.lang.String"/>
</subDataset>
<field name="filterDataSource" class="net.sf.jasperreports.engine.data.JRBeanArrayDataSource"/>
and in the table:
<jr:table>
<datasetRun subDataset="filterDataSet">
<dataSourceExpression><![CDATA[$F{filterDataSource}]]></dataSourceExpression>
</datasetRun>
<jr:column width="90">
<jr:columnHeader style="table_CH" height="30">
<staticText>
<reportElement x="0" y="0" width="90" height="30"/>
<text><![CDATA[Territory]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="table_TD" height="20">
<textField>
<reportElement x="0" y="0" width="90" height="20"/>
<textFieldExpression class="java.lang.String"><![CDATA[$F{territory}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
</jr:table>
I don't know whether this is the "orthodox" solution for this, but it worked for me.
Also, i posted this question on stackoverflow as well (http://stackoverflow.com/questions/4563176/jasper-table-component),
and someone seems to have found the answer:
But I haven't tested this (since it came a bit too late), but maybe it works for you.
Hope this helps!
Teo
Post Edited by teodanciu at 07/10/2012 19:59