Jump to content
Changes to the Jaspersoft community edition download ×

Variables evaluation time


abtrapp

Recommended Posts

 Hi!

Variables are evaluated at every row, correct?

Is there a way to change that (for example every group X?

Is there a documentation/book anywhere where not only the absolute basics are shown? I searched the web, bought and read some books, but nothing...

Tnx,

Anton

Link to comment
Share on other sites

  • Replies 7
  • Created
  • Last Reply

Top Posters In This Topic

 Thank you for your reply!

The only problem is: this are text fields. I know them (and the evaluation expression). I am using a variable there (for example $V{sample}. Even if I have the field in the group header and I set the evaluation time to group the "sample" variable will be calculated in every row of the dataset (I am using a call to a javascript function to set the variable.

 

I tried to calculate the "first" value, set the reset group to the group - but the variable is still evaluated at every row :(

I can see that as I am logging the calls of the Java function...

Link to comment
Share on other sites

 The simplified example code. The Calculator.calculate() can be a Java function which returns 123.45 as BigDecimal and prints a System.out.println("-->");

Result: whatever I try with the evaluation in the textfield and the variable (first / reset at group, ...) -> the Java function is called for every record. Bug, featrue or my error?

 

tnx!

Code:
<variable name="testVariable" class="java.math.BigDecimal" resetType="None">    <variableExpression>        <![CDATA[new com.mycompany.Calculator().calculate()]]>    </variableExpression></variable><... group ... group header ... band>    <textField evaluationTime="Group" evaluationGroup="ISINCCGroup" isBlankWhenNull="true">        <reportElement x="188" y="0" width="30" height="10" isRemoveLineWhenBlank="true"/>	<textFieldExpression class="java.math.BigDecimal"><![CDATA[$V{testVariable}]]></textFieldExpression>    </textField>
Link to comment
Share on other sites

 As I said, different resetTypes do not change the behaviour. This report is a "little" complicated so some fields are filled from Java, this is the only solution I have found to avoid the same calculation running for every row (put the calculation in the field). But with that solution I have to calculate almost everything twice (for the field and for the summary) which is ugly.

But as soon as I put the calculation into a variable it is evaluated every row, resetType does not change anything for me. My guess was, that a "first" on a group will only evaluate once in a group (which is sufficient and would be exactly what I need, but the first of the group is called for every row in the group).

Link to comment
Share on other sites

  • 2 years later...

+ 1. I have the same problem. Only fields have an evaluation moment. When you want to verify variables for a print condition missing this functionality makes it impossible to get it to work. Also tried everything... Did you already come up with a solution or workaround?

 

Thanks in advance!

 

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