Jump to content
JasperReports Library 7.0 is now available ×

problem with parameters


standup_75

Recommended Posts

I am sure that my parameter "thisMonth" is set, but why does this not work?

 

Code:
	<subDataset name="registrants">

<parameter name="thisMonth" isForPrompting="true" class="java.lang.String" />
<queryString>
<![CDATA[select to_char(usr.REGISTERED_DATE, 'yyyy') as year, to_char(usr.REGISTERED_DATE, 'mm') as month, count(*) as total from USR_ACCOUNT acc, TOL_USER usr, TOL_ADDRESS address, TOL_ADDRESS deliveryaddress
where acc.id=usr.id and acc.ROLES = '|PORTAL|' and usr.ADDRESS = address.ID (+) and usr.DELIVERYADDRESS = deliveryaddress.ID (+)
and usr.REGISTERED_DATE <$P{thisMonth}
group by to_char(usr.REGISTERED_DATE, 'mm'), to_char(usr.REGISTERED_DATE, 'yyyy')
order by to_char(usr.REGISTERED_DATE, 'yyyy'), to_char(usr.REGISTERED_DATE, 'mm') asc]]>
</queryString>
<field name="year" class="java.lang.String" />
<field name="month" class="java.lang.String" />
<field name="total" class="java.lang.String" />

</subDataset>

 

It only works when I do

 

Code:
[code] <subDataset name="registrants">

<parameter name="thisMonth" isForPrompting="true" class="java.lang.String" />
<queryString>
<![CDATA[select to_char(usr.REGISTERED_DATE, 'yyyy') as year, to_char(usr.REGISTERED_DATE, 'mm') as month, count(*) as total from USR_ACCOUNT acc, TOL_USER usr, TOL_ADDRESS address, TOL_ADDRESS deliveryaddress
where acc.id=usr.id and acc.ROLES = '|PORTAL|' and usr.ADDRESS = address.ID (+) and usr.DELIVERYADDRESS = deliveryaddress.ID (+)
and usr.REGISTERED_DATE <to_date('01.04.2007','DD.MM.YYYY')
group by to_char(usr.REGISTERED_DATE, 'mm'), to_char(usr.REGISTERED_DATE, 'yyyy')
order by to_char(usr.REGISTERED_DATE, 'yyyy'), to_char(usr.REGISTERED_DATE, 'mm') asc]]>
</queryString>
<field name="year" class="java.lang.String" />
<field name="month" class="java.lang.String" />
<field name="total" class="java.lang.String" />

</subDataset>

 

I actually have this problem in many places, knowing that I am using groups to create multiple reports in one pdf. So I have a main report with the definition of all groups and then as many subreport as I need, and this works fine, only the parameters find not their way through. Although I declare them in the main report like this:

Code:
[code] <subreportParameter name="thisMonth">
<subreportParameterExpression>
<![CDATA[new SimpleDateFormat("dd.MM.yyyy", Locale.ENGLISH).format($P{thisMonth})]]>
</subreportParameterExpression>
</subreportParameter>

thisMonth is also declared in the java part and then as parameter in the main report.

 

Any idea?

Link to comment
Share on other sites

  • Replies 4
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Have you tried printing out your parameter to make sure it has what you need? When you say it does not work, do you mean it is blank? If it isn't blank, then make sure that the main report is passing it down to the subreport correctly. I am not sure what the code looks like but I do know when I do this in iReport I have to make sure I set what parameters I want to pass down to the subreport.

 

Calvin

Link to comment
Share on other sites

Yes, I can print out $P{thisMonth} in the subreport, but the problem is that it is not taken into account in the subdataset, meaning the subdataset is empty and I obtain an empty graph when using it in this same subreport.
Link to comment
Share on other sites

Subdatasets do not automatically receive the report parameter values, you need to explicitly set their values:

Code:

<subDataset name="..">
<parameter name="thisMonth"/>
...
</subDataset>
...
<datasetRun name="..">
<datasetParameter name="thisMonth">
<datasetParameterExpression>..value for the param..</datasetParameterExpression>
</datasetParameter>
</datasetRun>

 

HTH,

Lucian

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