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

REPORT_PARAMETERS_MAP & subreport


2005 IR Help

Recommended Posts

By: Jeff - logicacmg

REPORT_PARAMETERS_MAP & subreport

2004-05-03 05:19

Sorry i have basically asked this question earlier, but have got no response, so I thought I would re-word.

 

How do I pass from Java the HashMap of values for the a SubReport, and how do I use the REPORT_PARAMTERS_MAP inbuilt variable (I assume in the Master Report to pass the HashMap through?), or do I not need to use this variable?

 

I have tried a few different calls to the subreport, but none of them are passing the values through. I am also passing a JRDataSource through and this works fine.

 

ANY help appreciated,

Jeff

 

 

 

 

By: C-Box - c-box

RE: REPORT_PARAMETERS_MAP & subreport

2004-05-03 06:24

You must declare the parameters given from MasterReport to SubReport in MasterReport's HeaderSection AND (!!) also in SubReport's HeaderSection with the same name and types if you want to put it first to master and then from Master to SubReport (and perhaps to nested subreport(s)...

 

So I've read it out of the documentation.

The BuiltIn variable "REPORT_PARAMTERS_MAP" you mean, is for easy transferring from Master to SubReport that you needn't define all the parameters single in the SubreportSection of MasterReportXML.

 

hth

C-Box

 

 

 

 

By: Jeff - logicacmg

RE: REPORT_PARAMETERS_MAP & subreport

2004-05-03 06:35

Thanks C-Box,

 

But can you clarify what I DO need to do for the built in REPORT_PARAMETERS_MAP. What name do I assign the Subreports HashMap to at the Java level, is this REPORT_PARAMETERS_MAP (I don't think so), and then what do I need in the <SubReport> section of the Master, and do I need to declare any other parameters in the actual subreport other than the ones I want. (ie Do I need to declare the hashmap?)

 

Sorry, if these seem basic questions, but the documentation has confused the heck out of me.

 

Thanks

Jeff

 

 

 

 

By: Chuck Deal - cdeal

RE: REPORT_PARAMETERS_MAP & subreport

2004-05-03 08:20

Here is a subreport definition from one of my reports. I have added in a reference to REPORT_PARAMETERS_MAP for you to see how to use it.

 

<subreport>

<reportElement positionType="Float" x="20" y="15" width="400" height="0">

<printWhenExpression><![CDATA[new Boolean($P{ShowDetails})]]></printWhenExpression>

</reportElement>

<subreportParameter name="ProcId">

<subreportParameterExpression><![CDATA[($F{proc_id} != null ? $F{proc_id} : new Integer(-1))]]></subreportParameterExpression>

</subreportParameter>

<subreportParameter name="MasterMap">

<subreportParameterExpression>$P{REPORT_PARAMETERS_MAP}</subreportParameterExpression>

</subreportParameter>

<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>

<subreportExpression class="java.lang.String"><![CDATA[$P{ReportPath} + "TESTRelatedCpcrs.jasper"]]></subreportExpression>

</subreport>

 

If you want to pass a COPY of the master Map, then use

new HashMap($P{REPORT_PARAMETERS_MAP}) instead.

 

 

 

 

By: Jeff - logicacmg

RE: REPORT_PARAMETERS_MAP & subreport

2004-05-03 10:04

C-Box (and others)

 

I tried basically that, and it did nothing. The report and the subreport generate correctly, but the values passed through in the HashMap did not display (therefore I assume did not get passed through).

 

Here is what I did, just in case I have not understood correctly what you have given me.

1. MasterHashMap is populated in Java Class (With Labels & values for the MASTER report ONLY)

2. SubreportHashMap is populated in Java Class (With Label values (Value values are passed in through the JRDataSource))

3. SubreportHashMap is added to MasterHashMap (MasterHashMap.put("subreportHash", SubreportHashMap); )

4. Report is called and displayed.

 

In the Sub Report, I have

<parameter name="labelName" class="java.lang.String"/>

<parameter name="labelDescription" class="java.lang.String"/>

 

These were originally added to SubreportHashMap in Step 2 above.

 

In the Master Report I have

<parameter name="subreportHash" isForPrompting="true" class="java.util.Map"/>

 

And the <subreport> section of Master is:

<subreport isUsingCache="true" >

<reportElement x="50" y="320" width="400" height="160" backcolor="#FFCC99"

isPrintRepeatedValues="true" isPrintWhenDetailOverflows="false"

mode="Opaque" isRemoveLineWhenBlank="false" positionType="Float" />

<parametersMapExpression><![CDATA[$P{REPORT_PARAMETERS_MAP}]]>

</parametersMapExpression>

<subreportParameter name="subreportHash">

<subreportParameterExpression>$P{REPORT_PARAMETERS_MAP}</subreportParameterExpression>

</subreportParameter>

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

<subreportExpression class="dori.jasper.engine.JasperReport">

$P{SubReport}

</subreportExpression>

</subreport>

 

 

I have tried just about every other possible combination (that I could think of here) and have had not luck.

 

I am assuming that I am meant to pass in the subreports values in their OWN hashmap. In this example there are only 2 values, but I have other reports waiting that have 100's or values being passed through to the subreport.

 

Any other suggestions,

Jeff.

 

 

 

 

 

By: Chuck Deal - cdeal

RE: REPORT_PARAMETERS_MAP & subreport

2004-05-03 10:22

Well, how are you attempting to use the information? We want to remove the assumption that they didn't get passed through, so that we can be sure of where the problem is. Since there are not a lot of people that have had this problem or that are replying with a solution, I would have to beleive that there is just something wrong with the XML definition.

 

Have you tried scaling back the report so that there is only a master and subreport and that you are doing simple things that are "easy" to verify?

 

If you are still having problems, you could always hook a debugger into the process and see where the problem lies...

 

 

 

 

By: Jeff - logicacmg

RE: REPORT_PARAMETERS_MAP & subreport

2004-05-03 11:24

I have "dumbed-down" the report as much as I can, and I still get the same problem.

 

I have tried with just 2 fields, the Name and the subreport HashMap, also no help. So to ensure that by "getting" the HashMap to work it does not kill the others, I have left the others (DataSource & Report) in the "Simplest" form.

 

The reports in the "simplest" form have:

Master:

Parameter "Name" of type String

Parameter "subHash" of type Map

Parameter "subDS" of type JRDataSource

Parameter "subReport" of type JasperReport

 

The SubReport has:

Parameter "labelName" of type String (SHOULD come from the "subHash" from Master)

Field "name" of type String (comes from the JRDataSoource)

 

It does not matter where the Subreport is defined in the Master report, eg Detail, Group etc, the same thing happens. The Master report is filled, the Subreport FIELD is filled, the Subreport Parameter is not (or is not displaying)

 

If I "print" the subreport as a standalone report, using the same hashmap from Java (ie subHash) and then the FIELD and PARAMETER values display.

 

I guess to start with, the following question should be answered:

Should I pass the Subreports HashMap to the Master reports HashMap in Java before calling the report like I am doing. eg.

MasterHashMap.put("subHash", SubreportHashMap)

Is this the correct way to do this?

 

 

 

 

By: Jeff - logicacmg

RE: REPORT_PARAMETERS_MAP & subreport

2004-05-03 12:24

OK, found it finally.

 

The problem was in the Master Reports <subreport> I had:

<parametersMapExpression><![CDATA[$P{REPORT_PARAMETERS_MAP}]]></parametersMapExpression>

 

When I should have had:

<parametersMapExpression><![CDATA[$P{subParam}]]></parametersMapExpression>

 

I knew the problem was around the use of REPORT_PARAMETERS_MAP.

 

So now the full <subreport> section looks like this (if anyone is interested in the solution)

 

<subreport isUsingCache="true">

<reportElement positionType="Float" x="20" y="80" width="400" height="0"/>

<parametersMapExpression><![CDATA[$P{subParam}]]></parametersMapExpression>

<subreportParameter name="subParam">

<subreportParameterExpression>$P{REPORT_PARAMETERS_MAP}</subreportParameterExpression>

</subreportParameter>

 

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

<subreportExpression class="dori.jasper.engine.JasperReport"><![CDATA[$P{SubReport}]]></subreportExpression>

</subreport>

 

Thanks all for your help,

Jeff.

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

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