Jump to content
Changes to the Jaspersoft community edition download ×

scriptlet and variables


maalto

Recommended Posts

Hi all,

I am having trouble using variables in a scriptlet.

I had it working some days ago, but now it stopped working again, without anything changed !?

I set the variable like this:

public void beforeReportInit() throws JRScriptletException

{

setVariableValue("temp",new SimpleDateFormat("yyyy-MM-dd").format(new Date()));

setVariableValue("month_last_day",new SimpleDateFormat("yyyy-MM-dd").format(new Date()));

System.out.println("temp variable: " + (java.lang.String)getVariableValue("temp"));

System.out.println("month_last_day variable: " + (java.lang.String)getVariableValue("month_last_day"));

 

Both variables are Calculation type system. What might be worng ? Is there some other settings somewhere ? Even the println prints the value correctly, but null values are in the report fields as $V{month_last_day} and $V{temp}.

Ireport version 2.0.2

 

I am quite lost now, please help ASAP.

 

BR. Mike

Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Yes !

I figured it out... I must have changed the scriptlet execution to beforeReportInit(), but now I put it to afterReportInit() and it works.

And another point in using scriptlet and subreports in separate groups is to put the variable reset type to report, otherwise the variable will loose its value after detail-band exec.

 

BR. Mike

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