Jump to content

How to implement a conversion method?


darya

Recommended Posts

Hi,

 

I want to convert a long value into a String (for a patternized duration) and have a method which does right this conversion.

 

But how on earth can implement or use this method in iReport :whistle: ?

 

Any hints are welcome :)

 

Regards,

darya

Link to comment
Share on other sites

  • Replies 11
  • Created
  • Last Reply

Top Posters In This Topic

It seems that I wasn't clear with my question :unsure: .

 

The $P{myLongParameter}.toString() is too less.

 

I have a method that displays the duration, say

public String getDuration(long l) {...}. This method displays the duration as I want it to be displayed.

 

The question is now, how can I make this method known to iReport?

 

Regards,

Darya

Link to comment
Share on other sites

Ok, seems that I had to answer this question myself :S .

 

I got my own class integrated with iReport and share the steps with you as shown below:

 

go to your jasperreports home directory

go to the lib directory and copy jdt-compiler-3.1.1.jar into your clipboard

go to your iReport home directory and paste jdt-compiler-3.1.1.jar into the lib directory

rename or delete the original file jdt-compiler.jar

start your iReport

go to the file menu Tools->Options and click the Compiler tab folder

Under Compiler select JDT Compiler (need jdt-compiler.jar) and click Save

to add your class to iReport's classpath, go to menu Tools->Classpath

add your own class and click on Save classpath

[/ol]

 

I do this broad explanation because I saw this similar question asked again and again. This feature of using one's own class is not well documented (at least I couldn't find a hint :blink:).

 

When one moderator read this, I recommend that we create a FAQ list with common problem solutions explained like this one.

 

Regards,

darya

Link to comment
Share on other sites

A simpler approach would be to use the scriptlet functionality in iReport.

 

First compile your class and put it into a .jar file. Add that .jar file to your classpath as you decsribed previously. Go to Report Properties under the edit menu and on the scriptlet tab tell it to use your scriptlet class.

 

You can now use $P{REPORT_SCRITPLET}.yourownmethod() to reference any method in your class. For my reports, I have put all my methods into a single class in a .jar, made sure that iReport has a path to it and also made sure that jasper reports has a path to it as well. This way whenever I need to add a new method to my collection I simply update my .jar and I'm done.

Link to comment
Share on other sites

darya wrote:

:pinch: Couldn't you post that earlier?
Regards,
darya

 

Get a grip on reality: most posters only visit occaisionally and even frequent posters have difficulty keeping track of what's going on because there's no email notification of changes to threads that you are involved in. It's really annoying for ppls trying to help out, so take a chill pill and be grateful for the excellent FREE assitance that has been provided to you

Link to comment
Share on other sites

Calm down.

 

First of all I did help myself in this thread :) .

 

Second, I was very nice to share my wisdom here, and this even for FREE ;) .

 

Third, don't you think you should restrain yourself a little bit before insulting me :sick: ?

 

I think the emoticons I used in my posts all speak for themselfs. If YOU feel upset send a private message to me but don't do it in public, if you want beware your social behavior.

Link to comment
Share on other sites

hi all,

 

i need to pass a set of formatting parameters at runtime to be applied to certain fields. for eg: say a param mask_ssn to mask the first 4 digits of ssn and other such formatting params. is there a way to accomplish this with ireport??? i've just started working on ireport and this is one particular requirement.

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