Jump to content
We've recently updated our Privacy Statement, available here ×

Can use a parameter in a table element ?


stinus

Recommended Posts

I 've creayted a report template that is used in my java code to generate a pdf report. Everything works fine except the filling of the parameter totalSize which is placed in a columnfooter. The value is always null in the report when passed by the java code. Is it possible to display a parametervalue like this ? I suppose it is, when I use the default expression (see below) it 's displayed in the column footer just fine...

Java code :

Map parameters = new HashMap();       

parameters.put("totalSize", 99999.99);

parameters.put("TableDataSource", dataSource);  

iReport :

    <subDataset name="TableData">
        <parameter name="totalSize" class="java.lang.Double"/>
    </subDataset>   

    <parameter name="TableDataSource" class="net.sf.jasperreports.engine.data.JRBeanCollectionDataSource"/>

 

                <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="TableData">
                        <dataSourceExpression><![CDATA[$P{TableDataSource}]]></dataSourceExpression>
                    </datasetRun>

                    <jr:column width="35">
                        <jr:columnHeader style="table_TD" height="120" rowSpan="4">

                              ..............................

                        <jr:columnFooter style="table_TD" height="94" rowSpan="1">
                            <textField>
                                <reportElement x="0" y="0" width="35" height="15"/>
                                <textElement textAlignment="Center" markup="none">
                                    <font isBold="false" isItalic="true"/>
                                </textElement>
                                <textFieldExpression><![CDATA["total"]]></textFieldExpression>
                            </textField>
                            <textField>
                                <reportElement x="0" y="15" width="25" height="15"/>
                                <textElement textAlignment="Center">
                                    <font size="5" isBold="true"/>
                                </textElement>
                                <textFieldExpression><![CDATA[$P{totalSize}]]></textFieldExpression>
                            </textField>
                        </jr:columnFooter>

 

With defaultexpression :

    <subDataset name="TableData">
        <parameter name="totalSize" class="java.lang.Double">

              <defaultValueExpression>1000.00</defaultValueExpression>

        </parameter>
    </subDataset>  

Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Problem solved, I was forgotten to put the parameter in the datasetRun element....

 

<datasetRun subDataset="TableData">


                        <datasetParameter name="totalSize">


                             <datasetParameterExpression><![CDATA[$P{totalSize}]]></datasetParameterExpression>                       

                         </datasetParameter>

                        <dataSourceExpression><![CDATA[$P{TableDataSource}]]></dataSourceExpression>

Link to comment
Share on other sites

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...