hovendal Posted July 13, 2009 Share Posted July 13, 2009 Dear forum I have some problems with passing a parameter to my 2nd nested subreport.I am using JRBeanDataSource, and in my master report, i have a "common" bean, that hold common fields as date, username, etc. and java NumberFormat object. This is because the user needs to be able to e.g specify the number of decimal fragments. The NumberFormat object is set in the common report controller which all specific controllers extend. The specific reports also have their own bean which extends the common reports bean, to have some specific fields - for instance to use with subreports.My problem occurs when I try to pass my NumberFormat object from the master report to the second nested subreport. Please see code for explanation of passing hierachi. Thanks for your help!Code:Passing from master:<subreportParameter name="numberFormat"><subreportParameterExpression><![CDATA[$F{numberFormat}]]></subreportParameterExpression></subreportParameter>To:<parameter name="numberFormat" isForPrompting="false" class="java.text.NumberFormat" />In 1st subreportPassing to second:<subreportParameter name="numberFormat"><subreportParameterExpression><![CDATA[$P{numberFormat}]]></subreportParameterExpression></subreportParameter>and recieving in secod:<parameter name="numberFormat" isForPrompting="false" class="java.text.NumberFormat" />Using the parameter:<textFieldExpression class="java.lang.String"><![CDATA[$P{numberFormat}.format($F{size})]]></textFieldExpression>returns null, so field value is blank... Link to comment Share on other sites More sharing options...
Teodor Danciu Posted July 13, 2009 Share Posted July 13, 2009 Hi, Maybe the field is not blank, but actually not appearing at all due to the fact that the subreports do not have a datasource and that their whenNoDataType attribute is not set to AllSectionsNoDetail, as it should. I hope this helps.Teodor Link to comment Share on other sites More sharing options...
hovendal Posted July 13, 2009 Author Share Posted July 13, 2009 The subreport is indeed not blank - only the textfield where i am trying to format the number. It has a datasoruce provided via the JrBeanDataSource like show below in the code, where floors ofcourse is a collection of Floor beans. All data available in the Floor beans are shown correctly, and if I remove the numberformat part, the "size" field is printed correctly.I am not sure what the whenNoDataType attribute is for, but it is not configured in my jrxml file, so it is set to default i guess.Does this make any sense?It appears as if my numberFormat object is null in the subsubreport. If I try to print e.g getNumberOfFractionDigits the value in the subreport is null (blank) while if I print it in the master report, where it is a field, it correctly prints the value specified by the user...I havent tried printing in the "middle" subreport.Code: <dataSourceExpression><![CDATA[new JRBeanCollectionDataSource($F{floors})]]></dataSourceExpression> <subreportExpression class="java.lang.String"><![CDATA["floors.jasper"]]></subreportExpression> Link to comment Share on other sites More sharing options...
Teodor Danciu Posted July 13, 2009 Share Posted July 13, 2009 Hi, Try print the String representation of the numberFormat object itself, using String.valueOf(Object).Just so that we make sure which objects are null. Might be that the numeric field is null. Thanks,Teodor Link to comment Share on other sites More sharing options...
hovendal Posted July 13, 2009 Author Share Posted July 13, 2009 Hi,Printing the following in each of the three parts - master-, sub- and subsubreport: Master: String.valueOf($F{numberFormat})Sub1 (building): String.valueOf($P{numberFormat})Sub2 (floor): String.valueOf($P{numberFormat}) With the following results:Master: java.text.DecimalFormat@674dcsub1: java.text.DecimalFormat@674dcsub2: null So it is pretty obvious now, that the object itself is indeed null :( Am I dooing the passing of the parameters wrong? Link to comment Share on other sites More sharing options...
hovendal Posted July 13, 2009 Author Share Posted July 13, 2009 Found the problem, so nvm!Thanks for your help anyway :) 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