Jump to content

Can I use custom class for parameter type?


Recommended Posts

By: Tuan Le - lesoft

Can I use custom class for parameter type?

2003-10-15 12:56

I have a class com.abc.XYZ. Can I pass it into my HashMap object and use in my XML report?

 

Here is my code

 

com.abc.ZYZ myClass = new com.abc.XYZ();

parameters.put("SpecialClass", myClass);

 

my XML report

 

<parameter name="MyClass" isForPrompting="true" class="com.abc.XYZ"/>

 

Currently, it doesn't compile b/c it couldn't find my class. Is this b/c I don't have my class set in the CLASSPATH, or JasperReports does not support custom class for parameter?

 

Thanks!

Tuan

Link to comment
Share on other sites

  • 8 months later...
  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Hi,

I hope it's not too late.

I had to do the same thing. Here is what I have in my report and it's working in my application.

my class is in this package: com.goods.GoodsItem;

 

In my report I declared the parameter like this:

<parameter name="goodsItem" isForPrompting="true" class="com.goods.GoodsItem"/>

 

Before that I tried to use "/" instead "." and it did't works so it might have been the problem but I'm not sure.

 

I hope this will help you.

Post edited by: non_descript, at: 2007/05/04 13:41

Link to comment
Share on other sites

Hi,

 

Just a small note to add here.

Since JR 1.3.3, inner classes and arrays are supported as valid types for report parameters, fields and variables.

 

Your write these with dots and [], just like you would normally declare those variables in a Java program.

 

I hope this helps.

Teodor

Link to comment
Share on other sites

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