passing foundset to jasper not significant ?

I discovered with great surprise that it does not matter which foundset I hand over to Jasper.

In Jasper I print a field like this:
<! [CDATA [$ F {myDetailFoundSet.myFieldName}]]> </ textField expression>

I call the report like this:
plugins.jasperPluginRMI.runReport (myDummyFoundset. cReportNam, true plugins.jasperPluginRMI.OUTPUT_FORMAT.PRINT, null, null)

This works very well !

Question:
Why is this absolutely correct looped through the Foundset myDetailFoundSet even though I have myDummyFoundset specified in the call.
Which instance makes the skip to the next record of myDetailFoundSet?

I must mention that myDummyFoundset must contain only 1 record, otherwise all the detail rows of myDetailFoundSet will be re-printed for each
record of myDummyFoundset . This makes sense to me, that the skip-to-next-record happens in the foundset I passed to the plugin.

Thanks for any enlightenment

Alessandro,

The foundset argument passed to runReport is what is looped over, it is the variable in your scripting that contains the foundset you want the report for.
The expression ‘$ F {myDetailFoundSet.myFieldName}’ is a field (related foudset myDetailFoundSet, field myFieldName in selected record) that will be printed.
So there is no loooping over myDetailFoundSet.

Hope this heops,

Rob

Thank you rob,

In my understanding the report should work like you described above. This makes absolutely sense.

The reason why I opened this tread was , that I experience an other behaviour, then expected:

The “myDetailFoundSet” is looped true, not the passed “myDummyFoundset” !!
I never realized it since months because I seem to work fine until the passed “myDummyFoundset”
contained more then 1 Record, witch results to double output of all Records of myDetailFoundSet.

If I pass “myDetailFoundSet” it results to an output of

myDetailFoundSet.getSize() mutiplyed by myDetailFoundSet.getSize()

The world is strange sometimes…

by the way this is the report (containing relationfoundset filt_adpp_1 witch looped true. also its relation filt_adpp_1.adpp_pdpm. the foundset I pass can be anything )

<?xml version="1.0" encoding="UTF-8"?>

<jasperReport xmlns=“http://jasperreports.sourceforge.net/jasperreports” xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance” xsi:schemaLocation=“http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xs … report.xsd” name=“LohnPlus_Provis” pageWidth=“595” pageHeight=“842” columnWidth=“553” leftMargin=“42” rightMargin=“0” topMargin=“42” bottomMargin=“20”>






















































Alessandro,

I remember now again how it works, slightly different from my post above.

Jasper reports asks for the next data, the plugin will loop over the main foundset and all related foundsets that are used.
So if you use a related foundset in your report, that will be looped over as well.

Compare the behaviour to sql-based report.
When you do a report on the orders table: ‘select orderid from orders where customerid = ?’ all orders are shown once.
If you add related info via a join: ‘select orders.orderid, order_detail.product_name from orders join order_detail on orders.orderid = order_detail.orderid where customerid = ?’, the orderdetails will be looped over as well.

If you do the same thing foundset-based you would use fields orderid and orders_to_order_details.product_name in your report and get the same results.

Hope this makes it clear.

Rob

Thank you Rob, this makes really sense for me, but as I wrote in earlier posts,
I experience an other behaviour in my case.

I created a little Test-Solution for demonstration purpose. It prints a view records
of the bug_db.

One button passes the Dummy-Foundset with 1 record, and the other button passes
the Dummy-Foundset with more then 1 record.
In both cases, the real printed detail-records are from the same foundset (a Relation).

You can see, that depending on the Record-Count of the passed (but unused ) Dummy-
Foundset, the detail records are printed multiple time.

This is the Demo-Video: http://youtu.be/r0pfGZs7xq8
The Solution and the Report is attached hier: [attachment=0]testSolutionAndReport.zip[/attachment]

Thank you, for making this more sense to me.

testSolutionAndReport.zip (6.13 KB)

Looking at your video, that behavior seems correct. When you use FoundSet reporting, you need to be very careful with which fields/relations you use in your report. When Servoy passes the data to jasper, it creates the equivalent of a cartesian product between all of the related record. Its also always in the context of the foundset you pass. So if your foundset has 2 records in it, and you use a related foundset, your going to get 2 times however many records in your related foundset.

I think you should take a step back and see exactly what you are trying to accomplish. If your end goal is a report based on the tbl_people table, then you should be passing a foundset based on tbl_people. Then use a relation to go from people to company.

Looking at the sample code you posted, you don’t seem to be using any columns from the base foundset there either. All of your field names are relationname.columnname. So why not just pass in the relation as the base foundset? I do see your using several relations:
filt_adpp_1
filt_adpp_1.adpp_pdp
filt_lspm

So your going to end up with 1 record for each tuple from the base foundset you pass in, plus all those relations.

If your goal here is dynamic foundset, do you realize you can pass in foundsets as parameters in your report, and use subreports for displaying the data from those different foundsets?

Some additional thoughts after I downloaded your sample…

stefanoni:
You can see, that depending on the Record-Count of the passed (but unused ) Dummy-
Foundset, the detail records are printed multiple time.

Why do you think its unused? The data from the report is always in the context of the foundset you pass in! so if you pass in myDummyFoundset in the jaser plugin call and that foundset has 2 records, your going to get at least 2 records in your jasper report. Just because you use the global relation in your report (test_relation_as_filter) doesn’t mean that’s all jasper will use. If your myDummyFoundset has 2 records, and your test_relation_as_filter has 2 records, your going to end up with a report of 4 records. Generally using an unrelated/global relation in a Jasper report isn’t advised because of this.
From your sample, the better approach would be to pass in the relation into the report…

plugins.jasperPluginRMI.runReport(test_relation_as_filter, ...)

Then in your Jasper report your fields that you add are the columns in test_relation_as_filter (ixtenant, name_full, etc) without the relation name prefix (so they come from the foundset you pass in)

Scott,

For me it’s crucial to understand, that a “Cartesian product between all of the related record” is created.

Also was too much to understand, that if I specify in the report a prefix (relation-Foundsetname), it leads to another tuple, respectively, this can be prevented by omitting the prefix, using directly the field-names of the passed foundset.

I have tried this with the test solution, and ultimately with the real report and eliminate any confusions.

Thank you for your rich and insightful response !

Best regards
Alessandro Stefanoni