Jump to content
Changes to the Jaspersoft community edition download ×

Handed a work project (only met Jasper Reports in April!!!) have a question


Recommended Posts

Due to the departure of a co-worker, I was handed a "query based" report to finish fro deployment.  Here is my problem.  The query is all developed and working but we have been asked to put in an additional field.   Due to the nature of the underlying data, we can not add this new piece of data to the existing join.   Several of us have discussed this issue and have come to the conclusion that we need to perform some magic using the existing Scriptlet that the original developer defined.  As I only met Jasper Reports in April I am having to "fast track" my learning process.   I am aware of an event handling method named afterDetailEval() and, if I interpret correctly, it runs after each detail row has been prepared for eventual display.   Since Scriptlets are, as I understand it, an "interface from Jasper Reports to Java" it would seem reasonable that I could introduce code which could make a connection to the software LIMS system, retrieve DataObjects based on the ID (which I can get in the report query, so that ID is available!), then use the LIMS API to get the DataObject that I need, retrieve the data, and "plug it in" to one of the report fields so that it will display in that field when the report is rendered.

In my current thinking, I might be able to get this done using afterDetailEval() and possibly a custom method  BUT I am seeing that through the JRDefaultScriplet, I and retrieve Parameters, Fields, and Variable but can ONLY UPDATE Variables.   Due to my unfamiliarity with the world of "all things Jasper",   this gives me some doubt as to whether I can indeed do this.  I am not sure that I have a firm grasp on just what Parameters, Fields, and variables are...  but I am "what they have" to get this done.

With that, my question boils down to this.....

I have a working query based report.   Will using a Scriptlet allow me to :

1) use a field from the query, 
2) run code based on a thrid party API using that field to retrieve data objects and retrieve a value from the data object,
3) then plug that data retrieved into one of the report fields so that it will display when the report renders?

Can this be done?

Thanks in advance for any responses to this inquiry,
Bob Ruth
Baylor College of Medicine, HGSC 

Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Due to your question being too long and not to the point, I'm not sure this is what you're asking but if you're trying to update a datasource statement using scriptlet, that's not possible.

On the other hand, if you're trying to update a field value based on a value retrieved from a query, that can be done. Dragging and placing a variable to a canvas will create a field that will display that variable content.

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