Jump to content
Changes to the Jaspersoft community edition download ×

Problem with returning subreport variable


bthale

Recommended Posts

I have a subreport that needs to return a string variable. I need this variable displayed in the Page Header. I have tried evaluation times of Now, Report, and Band, but alwys get null. I have debigged the data and the subreport variable is getting it's value from a field in the subreport. This field is not null.

How do I get the correct data back from the subreport.

 

Do I need to have the variable calculation set to something other than nothing?

 

Link to comment
Share on other sites

  • Replies 5
  • Created
  • Last Reply

Top Posters In This Topic

As ireport guide said, If you want to get a value from subreport you need to do those steps:

1. In the master report, create a new variable (let’s call it SUBBREPORT_VAR) that is type java.lang.String and

calculation type System.

2. Select the subreport element and open the Return Values property dialog by clicking the appropriate ... button.

3. Click the Add button to create the new return value; the Add/Modify variable dialog will appear.

4. Select a calculated value from the subreport’s variables.

5. Next, select a calculation type. If you want a subreport value to be returned as-is, select the type Nothing.

Good luck!

Link to comment
Share on other sites

I followed these instruction, but still get null returned. I know the variable is not null in the subreport, because I am displayiing it for debugging purposes.

 

There is also a calculation setting in the dialogs where you define a return variable. I'm not sure if it should be set to System also, but there is no option in the dropdown for System. Is this a bug?

Link to comment
Share on other sites

 Ok, I did some tests and this is what I got:

If in the subreport variable the "variable experssion" is empty - you will get null.

So, all the instration are the same except that in the master report the variable definations are:  

class="java.lang.String", incrementType="Report", calculation="nothing", resetType="Report"

And in the subreport the variable defination are:

class="java.lang.String", incrementType="none", calculation="nothing", resetType="none" and the Variable Experssion is not empty.

The result that I got was that in the master report I could display the subreport variable.

Good luck.

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