maalto Posted October 30, 2007 Share Posted October 30, 2007 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 More sharing options...
maalto Posted October 31, 2007 Author Share Posted October 31, 2007 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now