Yes exactly...

If you want to do in simpler way...

Code snippet
----------------------

//Do whatever query, main, sub, additional query based on previous query,
etc
//and fill the Collection of Maps
Collection<Map<String, Object>> myColl = new ArrayList<Map<String,
Object>>();
Map<String, Object> map1 = new HashMap<String, Object>();
map1.put("Field1","value1");
myColl.add(map1);

Map<String, Object> map2 = new HashMap<String, Object>();
map2.put("Field1","value1");
myColl.add(map2);

JRMapCollectionDataSource dataSource= new JRMapCollectionDataSource(myColl);
JasperFillManager.fillReport(jr, reportParameters, dataSource);
----------------------

You declare fields in jasper reports
Field1

Use that in the layout as $F{Field1}

To have a better control than the JRMapCollectionDataSource, 
you have to implement the JRDataSource interface,
check the samples
jasperreports-1.1.1\demo\samples\datasource directory
CustomDataSource.java

Regards,
Raffi




-----Original Message-----
From: Manfred Moser [mailto:[EMAIL PROTECTED]
Sent: Tuesday, April 25, 2006 9:11 PM
To: Dan Adams
Cc: S, Mohamed Raffi (Mohamed);
jasperreports-questions@lists.sourceforge.net
Subject: Re: [jasperreports-questions] running many queries in a report?


At some stage in the code you will fill the report eg. with

JasperFillManager.fillReport(jr, reportParameters,
dataSource);

All you have to make sure is that the reportParameters contains all the
values 
from your queries in a Map.

Eg. with totalCount 100

and that your jrxml references the parameter with $P{totalCount}. Use a text

field in iReport but change from $F to $P ...

Test it out with a hardcoded Map first and then fill the map from your data.

Manfred


Dan Adams wrote:
> I'm sorry, could you elaborate on that a bit? Or point me to an example?
> Thanks for your help.
> 
> On Tue, 2006-04-25 at 10:19 +0530, S, Mohamed Raffi (Mohamed) wrote:
>> Check out the Custom DataSource section, if there is any.
>> Basically you need to implement the JRDataSource and do your stuff in
there
>> and return a collection of Maps.
>> Jasper Engine will use that for the report rendering.
>> Don't forget to declare Fields and Parameters as required.
>>
>> Regards,
>> Raffi
>> -----Original Message-----
>> From: [EMAIL PROTECTED]
>> [mailto:[EMAIL PROTECTED] Behalf Of
>> Dan Adams
>> Sent: Monday, April 24, 2006 11:49 PM
>> To: [EMAIL PROTECTED]
>> Cc: jasperreports-questions@lists.sourceforge.net
>> Subject: Re: [jasperreports-questions] running many queries in a report?
>>
>>
>> Sorry, If I'm kind of new to this, but could you elaborate on getting
>> the datasource to run the queries and put them in parameters? I have the
>> jasper ebook and have read through it so I can reference that if need
>> be.
>>
>> On Mon, 2006-04-24 at 11:03 -0700, Manfred Moser wrote:
>>> Dan Adams wrote:
>>>> I have a report I want to do that, while it runs one main query, needs
>>>> to run many other small queries where it really only cares about
getting
>>>> one result from the query (such as a count or average). How is this
done
>>>> without creating a ton of subreports that don't print anything and just
>>>> return a result?
>>> You can just set parameters with these values. Just get your data source
>> to run 
>>> all the queries and put the results in different parameters. If you use 
>>> subreports or not is a different issue.
>>>
>>> manfred
>>>
>>>
>>>


-- 
Manfred Moser - [EMAIL PROTECTED]
CardioComm Solutions Inc.
201-3060 Cedar Hill Rd.
Victoria  BC V8T 3J5 Canada
Phone: (250) 744 1822 Ext. 230
Fax: (250) 744-1866
http://www.cardiocomm.com


-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
jasperreports-questions mailing list
jasperreports-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jasperreports-questions

Reply via email to