Jump to content
JasperReports Library 7.0 is now available ×

Newbie needs help


Recommended Posts

By: Gopal - ggopal

Newbie needs help

2005-04-05 08:50

Hi Jasper Experts:

 

First of, I am not an expert either in java /jasper. I can pretty much hack something together in java and that's what I am doing currently.

 

I have a java application that does processing of data. Basically, reads data from a data source, calls a validator, calls an output formatter and writes out an output record (text file format).

 

Now, in the validators & formatters routine, I need to incorporate a reporting mechanism.

 

I would prefer to design the report template outside of my java app using any of the available jasper designer. That's cool.

 

Now, within my java app, I need to do the following:

 

1) load the pre-defined report template -- don't know how ...

2) Call jasper api's to write out detail lines as I process each input record -- don't know how ...

3) finally, at the end of processing, I need to be able to either preview it, export it to pdf etc ... again, these options to be set in my java app. again don't know jasper api to accomplish this.

 

So, I would appreciate very much if someone out there can provide me with some small examples. I am looking at the docs but getting confused.

 

Thanks for your help, it's much appreciated,

-- Gopal

 

 

By: Gopal - ggopal

RE: Newbie needs help

2005-04-05 14:48

Ok, folks ... I know and understand that I have been looking at solutions in this forum and also the /demo/examples dir after I have downloaded the zip file. Looks good so far.

I have also downloaded ireport and designed my report template.

 

The only thing remaining to do is to integrate the template into my code.

 

I think I can load the compiled report as follows:

JRloader.loadobject(filename);

 

So, I am making some progress, but if someone can point me to the solution in how I can dynamically assign values to fields that I have created in ireport detail line and print (not to a printer, either on screen/export to pdf), I would appreciate it very much.

 

-- Gopal

 

 

By: Gopal - ggopal

RE: Newbie needs help

2005-04-05 16:29

Ok, I have been reading thru this forum to find some answers to my problem. Basically, from my reading whenever anyone has talked about dynamically creating reports, the reply seems to be to look at noxmldesign. I am looking at noxmldesign and trying to understand it. So, folks I am working on getting some help by doing looking at forums, sample code etc.

 

My problem is a little bit different and of course, since I am a newbie at jasperreports ... I seem to be good at breaking stuff ...

 

Anyway,

1) report has been created and compiled - no problems. It was actually a breeze, thanks to this forum.

 

2) Need to load the compiled report in my java app. I think I know how, but again will appreciate some clarification.

 

3) Most importantly, I need to know the following (which noxmldesign doesn't do ... maybe I am stupid)

 

1) First of all, there is no database involved as datasource. My java app wants to create error report based upon data validation. So, after reading input and processing 1st record, I would like to print the 1st record details/errors to my report detail line (contains only 3 fields). Then, go on to process the 2nd, print the 2nd detail line, process 3rd ... you get the picture.

 

 

 

 

By: Gopal - ggopal

RE: Newbie needs help

2005-04-05 16:29

Ok, I have been reading thru this forum to find some answers to my problem. Basically, from my reading whenever anyone has talked about dynamically creating reports, the reply seems to be to look at noxmldesign. I am looking at noxmldesign and trying to understand it. So, folks I am working on getting some help by doing looking at forums, sample code etc.

 

My problem is a little bit different and of course, since I am a newbie at jasperreports ... I seem to be good at breaking stuff ...

 

Anyway,

1) report has been created and compiled - no problems. It was actually a breeze, thanks to this forum.

 

2) Need to load the compiled report in my java app. I think I know how, but again will appreciate some clarification.

 

3) Most importantly, I need to know the following (which noxmldesign doesn't do ... maybe I am stupid)

 

1) First of all, there is no database involved as datasource. My java app wants to create error report based upon data validation. So, after reading input and processing 1st record, I would like to print the 1st record details/errors to my report detail line (contains only 3 fields). Then, go on to process the 2nd, print the 2nd detail line, process 3rd ... you get the picture.

 

 

 

 

By: Gopal - ggopal

RE: Newbie needs help

2005-04-05 16:34

Sorry guys, couldn't finish my earlier post. Fat fingers pressed the enter key before I was done.

 

Anyway, I know that the answer is probably simple, but I have not been able to figure it out, yet and I understand that the java/jasperreports experts in this forum can probably figure it out in 3 secs ..

 

However, I am hoping that someone takes it in their heart to give me some help. I have spent the better part of today trying to read thru this forum looking for some answers and I am just about to give it up. code snippet would be helpful ...

 

Thanks a lot,

-- Gopal

 

 

By: C-Box - c-box

RE: Newbie needs help

2005-04-07 14:51

As far as I unterstand your posting right I would advice you to collect all your data into a CustomDataSource... so I think you are processing some data and at each stage you want to collect some eventually errors and after finishing print the error report.

 

So make a CustomDataSource (e.g. create an ErrorObject that have your three fields that the report should print) fill a collection of that ErrorObject while processing your main routine... if the collection contains some elements so probably some errors occured (so you have to put each new ErrorObject into that collection when one is happening)... so you must create a JRBeanCollectionDataSource (take a look at the datasourceSample) and after that just load your predesigned report, compile it (if neccessary) and fill it with that JRBeanCollectionDataSource.

 

then for each item of the collection the report should show a line....

 

this is just how I would do it and like I did interpret your thread here.

 

hth

C-Box

 

 

By: Gopal - ggopal

RE: Newbie needs help

2005-04-08 08:38

Thanks c-box. I kinda figured it out. I was thinking about your solution, but I implemented it differently. You are right on the money as far as processing goes. It's purely batch. For each input record, perform validation on all fields, format all fields and create an errata in the process.

 

I implemented the defaulttablemodel in jtable and used that to create the jasper report. I also added extra code to create a preview window.

 

The examples and this forum did help, but it was just time consuming and I was getting nervous about not finding a solution. Finally, I went to bed and slept and next day early morning, the solution was staring at my face.

 

Thanks for replying thoug. I do appreciate that.

 

regards,

-- Gopal

 

 

By: MohanProint - mohanproint

Loading compiled xml file

2005-04-28 21:36

How do i use the pre compiled xml file (jrxml) in the report generation. Now i am using the xml file, so i first loaded the xml file and compile the xml file finally i am passing the compiled xml file in the fill report.

 

Its take time to compile the xml, can u help me how to load the pre comiled xml (jrxml) to filling the report.

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