Jump to content
Changes to the Jaspersoft community edition download ×

How to return variables from Report to Java


vmstepanov

Recommended Posts

Hi ALL,

How can I return value of variable from jasper report to caller java code?

 

Pseudo-code:

set report parameters

run report

get some variable back from report

make decision depending on previous step

 

Or

 

Map parameters = new HashMap();

parameters.put(key, "value");

 

JasperPrint jasperPrint = JasperFillManager.fillReportToFile(fileName, parameters, getConnection());

 

String pageCount = jasperPrint.getVariableValue("PAGE_COUNT"); //METHOD NOT EXISTS, just fantasy

 

followingJavaProcessing(pageCount);

 

I believe this issue could be solved using scriptlet, but I have no idea how to return something from scriptlet in multithreaded environment.

Link to comment
Share on other sites

  • 11 years later...
  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

BaseReportFiller filler = (BaseReportFiller) JRFiller.createReportFiller(DefaultJasperReportsContext.getInstance(), jasperReport);
JasperPrint jPrint = filler.fill(parameters, getConnection());
Object pageCount = filler.getVariableValue("PAGE_COUNT");

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