Jump to content
We've recently updated our Privacy Statement, available here ×

Pass parameters from jasper to java


Syriusz

Recommended Posts

  • Replies 5
  • Created
  • Last Reply

Top Posters In This Topic

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

Link to comment
Share on other sites

  • 2 weeks later...

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

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