parameter iterator

By: nay - nay
parameter iterator
2002-09-12 03:20

1- Can I iterate a parameter in the JasperTemplate.xml (if my parameter is a Collection for example) ?

2- Can I have a java.lang.Object field and my objectField have 1 collections attributes and I want to access to the element of the it possible ?


By: Teodor Danciu - teodord
RE: parameter iterator
2002-09-14 01:20


I'm not sure I know what you want to do.

If your report data comes from a Collection and not
from a JDBC data source, then you should consider
using a custom JRDataSource imeplementation
that would wrap this collection so that you could
supply it to the reporting engine as data source.
See the "datasource" sample provided to see how
you can achieve this.
Maybe the default JRDataSource implementations
found in the package are
exactly what you need.

If this is not the case and you just want to supply
the Collection as a report parameter, I can only say
that you would be able to iterate through it as the
report is filled using scriptlets.
Of course, you don't have to use scriptlets if you
devise a way to call iteration on your Collection
using probably "dummy" report variables.

Anyway, you should note that all the
JasperReports expressions are in fact real Java
expressions. They only have a special syntax
added to support referencing report parameters,
fields and variables, but you can do anything you
want with them.

If the report expressions tend to complicate and
you need iteration, feel free to create your own
classes, with static methods in them,
to encapsulate all the code you need to place in
the expression. You only have to make sure that
those classes will be available in the classpath and
you use their entire name (including the package)
when you reference them in the report expressions.

And yes, you can have report fields that are in fact
Collection objects, but I imagine you have to use
custom JRDataSource implementations to setup
all this, as I already suggested.

I hope this helps.
2001 JI Open Discussion's picture
Joined: Aug 10 2006 - 3:26am
Last seen: 16 years 10 months ago

0 Answers:

No answers yet