I want to share my 'solution' because I feel it is a little convoluted. And 
usually as soon as I feel convoluted it means that I am a little screwed.

anyway a subreport is expecting the object to be a JRDataSource. so after a 
little mucking around:

first create a Java List (NSArray will not work)
I have a to-many from my EO to pwoMileStone

List<PWOMileStone> objectMSList = null;
try {
     objectMSList = new ArrayList<PWOMileStone>();
                         
int i;
for (i=0; i<theEO.pwoMileStones().count(); i++){
     objectMSList.add( theEO.pwoMileStones().objectAtIndex(i) );
}                        

} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

then add it to the parameters

parameters.put("pwoMileStones", new JRBeanCollectionDataSource( objectMSList ));

then in iReport:
create a Parameter to match the incoming parameter (type is object)
drop a sub report on the page:
Connection type: Use a datasource expression
DataSource expression:  $P{nameToMatchTheIncomingParameter}

Now that you have the datasource you can refer to the Fields to get at the 
instance variables.
in my case:
msDate
msDescription 

IMPORTANT:   

you must create getters in your Model. If you have an attribute msDate, you 
must create a getter or JasperReports will not see the attribute.

public NSTimestamp getMsDate() {
    return this.msDate;
}

I could have passed the List to iReport and then in the Data Source Expression 
wrapped it in a 'new 
net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($P{parmName})


lots of cleaning up to do, but it is working.

Thanks for ERJasperReports. they really work well.

Ted

--- On Mon, 1/21/13, Kieran Kelleher <[email protected]> wrote:

> From: Kieran Kelleher <[email protected]>
> Subject: Re: jasperreport help please
> To: "Theodore Petrosky" <[email protected]>
> Cc: "WebObjects Development" <[email protected]>
> Date: Monday, January 21, 2013, 9:44 AM
> I would say you need a sub-report ...
> and I can't help you there since I did not need sub-reports
> for the project I did with Jasper Reports a few years ago,
> plus I have not worked with jasper in quite a while. So you
> need to look at the Jasper API/docs on sub-reports. I am
> guessing it will require something like returning the
> relationship objects as a JRDataSource to feed each
> sub-report instance.
> 
> -Kieran
> 
> 
> On Jan 20, 2013, at 12:36 AM, Theodore Petrosky <[email protected]>
> wrote:
> 
> > I hope someone has worked this out because I am so
> tired.
> > 
> > I am creating a report and I recently add a to-many
> relationship to my EO. The EO is printing and I understand
> how to use iReport to add my Fields. but I don't understand
> how to get this to_many to print.
> > 
> > if I add a field of pwoMileStones, I get the Array of
> objects. So I followed Kieran's example and used the
> underscore to get to the attributes. 
> > 
> > so:
> > pwoMileStones_msDate gives me an Array. Actually
> $F{pwoMileStones_msDate} in the page prints as:
> > 
> > MS Date: (2013-01-30 00:00:00 Etc/GMT, 2013-01-29
> 00:00:00 Etc/GMT, 2013-02-27 00:00:00 Etc/GMT)
> > 
> > I thought I could use a Report Group but that isn't
> working out. at lease the docs that I am reading doesn't
> seem to make sense for this problem.
> > 
> > I am at a loss. pwoMileStones is a array of objects.
> the object has two attributes (msDate, msDescription).
> > 
> > Do I need a subReport?
> > 
> > Going to bed. Will pick it up tomorrow. Or rather in a
> few hours.
> > 
> > Ted
> > 
> > 
> > 
> > _______________________________________________
> > Do not post admin requests to the list. They will be
> ignored.
> > Webobjects-dev mailing list      ([email protected])
> > Help/Unsubscribe/Update your Subscription:
> > https://lists.apple.com/mailman/options/webobjects-dev/kelleherk%40gmail.com
> > 
> > This email sent to [email protected]
> 
> 

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to