teodanciu Posted December 29, 2010 Share Posted December 29, 2010 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! TeoCode: 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> Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now