Pass parameters from jasper to java

0

Hi,

My client wants to create Report in Jasper witch pass parameters to java application. Is is possible?

I know how to make it in other way (from java to jasper). 

 

best regards Syriusz

Syriusz's picture
Joined: Oct 10 2019 - 4:43am
Last seen: 1 week 5 days ago

5 Answers:

0

Well sometimes I also needed some results from the generated report back in my calling (java)application. So there are several ways to do that.

First you can create a scriptlet class where you implenent the different methods to collect some values in your scriptlet class. (e.g. some sums or some averages from total summary band or whatever). After the report is finished with the fill process you can reuse the scriptlet object to do some further work.

Second approach I've sometimes done is to parse the generated JRPrintObject (you can iterate through all pages, through all elements) and can get some values from special fields or whatever -> just mark them with unique keys or url anchor expressions or whatever else). So this is also quite a simple way to get something back from your report.

Of course you can also use some Exporters (CSV/EXCEL/TXT/....) to get the data back in a programmatically way to interprete them further.

So nothing is impossible... the limit is the sky ;-)

hth + regards

C-Box

C-Box's picture
2251
Joined: Jul 19 2006 - 5:58pm
Last seen: 5 hours 51 min ago
0
Syriusz's picture
Joined: Oct 10 2019 - 4:43am
Last seen: 1 week 5 days ago
0

Not sure what you actually want to get back from your generated report to your calling java app???

So of course you can also use some webscrapers (I've no experiences with such tools) and extract content from generated (html) content. Also the CustomDataSource that wraps your ResultSet/Data could be an approach... so that's why I wrote nothing is impossible... it depends what exactly you want to do?

Like I said: for just getting some calculated sums from JasperVariables in some bands the scriplet or parsing the JasperPrintObject way would be the easiest was (IMHO)

regards

C-Box

C-Box's picture
2251
Joined: Jul 19 2006 - 5:58pm
Last seen: 5 hours 51 min ago
0

Firstly, Thank You for your patience :) 

My Client wants something like this:

1. User go to jasper server, choose raport "X" and input parameters like ID or "version of report"

2. Jasper pass paremeters to Java Application "Y" 

3. "Y" take paremeter like ID and collect data from others systems in Client network. Something like "Select * from SomeTable where id = Input_ID

4. "Y" insert all collected data to database "DB" and finish work

5. Report "X" starts to generate report from "DB" with new data

Is it possible? 

 

regards

Syriusz

Syriusz's picture
Joined: Oct 10 2019 - 4:43am
Last seen: 1 week 5 days ago
0

Well I'm not so familiar with the JasperReportsServer as I normally just use the default JasperReports Library within "normal" JavaApps. Sorry!

But I could imagine something like this:

Report1 is just responsible to get the parameters from User

a ReportScriplet for Report1 is responsible to pass the parameter to your JavaApp that fills the data synchronous by the passed through parameters into the database (so report1 will take a while e.g. AtReportStarted-EntryPoint ( beforeReportInit() ) of scriplet until the JavaApp finished the preparation of data

Report1 contains a SubReport( so this is Report2) that actually just  collects these Data from the currently filled Scriplet class (you could return a different Connection or perhaps a (Custom)JRDataSource instance if needed) and returns the results to the User

So just an idea.... but perhaps you can do something other with built-in features in JasperReportsServer that I don't know. Looks also a bit of "AdHoc ETL" !? :-)

Perhaps a Staff member or a JasperReportsServer PowerUser will answer this topic also??!??

hth + regards

C-Box

C-Box's picture
2251
Joined: Jul 19 2006 - 5:58pm
Last seen: 5 hours 51 min ago
Feedback