Jump to content

NumberFormat object to nested subreport


hovendal

Recommended Posts

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

  • Replies 5
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

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

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@674dc

sub1: java.text.DecimalFormat@674dc

sub2: 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

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