Jump to content
Changes to the Jaspersoft community edition download ×

passing report parameter to a subdataset


Recommended Posts

By: fduo - fduo

passing report parameter to a subdataset

2006-05-12 07:48

Hello,

 

I am trying to pass a report parameter into a dataset. I was trying hard, but I didn't manged to get it working. Maybe someone sees a solution?

 

Here is the Code of the dataset:

 

- <subDataset name="SubDataset1" whenResourceMissingType="Null">

- <parameter name="laufnummer1" isForPrompting="false" class="java.lang.String">

- <defaultValueExpression>

- <![CDATA[ (String)$P{REPORT_PARAMETERS_MAP}.get("laufnummer")

]]>

</defaultValueExpression>

</parameter>

- <queryString language="sql">

- <![CDATA[ select r.id, a.agentur, r.clientstatus, decode(r.origin,null,'PortX','SCA') as Quelle from sumexii.t_dh_rech r, sumexii_security.t_allocation a where r.reserve3 = $P!{laufnummer1} and r.allocation = a.id

]]>

</queryString>

<field name="ID" class="java.math.BigDecimal" />

<field name="AGENTUR" class="java.lang.String" />

<field name="CLIENTSTATUS" class="java.lang.String" />

<field name="QUELLE" class="java.lang.String" />

</subDataset>

 

- The Report parameter "laufnummer" should be passed to the dataset parameter "laufnummer1". My last try was with the REPORT_PARAMETERS_MAP.

 

The Code of my report parameter:

<parameter name="laufnummer" isForPrompting="true" class="java.lang.String">

- <defaultValueExpression>

- <![CDATA[ "8923"

]]>

</defaultValueExpression>

</parameter>

 

 

I would be really happy if someone could help me.

Thank you for reading this.

Regards

Fabio

 

 

 

 

By: Lucian Chirita - lucianc

RE: passing report parameter to a subdataset

2006-05-16 01:42

Hello

 

Report data is not visible inside subdataset expressions, subdatasets have completely separate data/name spaces. Therefore, when you use $P{REPORT_PARAMETERS_MAP} in an expression of a subdataset, you don't get the parameters map of the report but the parameters map of the subdataset (the name is indeed confusing and can lead to a wrong assumption).

 

If you want to pass a report parameter to a subdataset, you have to use a <datasetParameter> element when instantiating the dataset (i.e. in your <datasetRun> element):

<datasetRun subDataset="SubDataset1">

<datasetParameter name="laufnummer1">

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

</datasetParameter>

</datasetRun>

 

Note that you can use the same for the subdataset parameter, it doesn't conflict with the report parameter.

 

Take a look at the demo/sample/charts/SubDatasetChartReport.jrxml sample and at the crosstab samples, you can see there how to use subdataset parameters.

 

HTH,

Lucian

Link to comment
Share on other sites

  • 9 years later...
  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

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