Jump to content
Changes to the Jaspersoft community edition download ×

parameter iterator

Recommended Posts

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 collection....is 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 dori.jasper.engine.data 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.


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