abtrapp Posted May 29, 2011 Share Posted May 29, 2011 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 More sharing options...
Portlight Posted May 31, 2011 Share Posted May 31, 2011 Anton,for each variable you place in your report - if using ireport as your designer - there is a box which allows you to control when the variable is evaluated. I have included a picture of what this box looks like. Link to comment Share on other sites More sharing options...
abtrapp Posted June 1, 2011 Author Share Posted June 1, 2011 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 More sharing options...
Portlight Posted June 1, 2011 Share Posted June 1, 2011 If you can post your jrxml I can look at it and see if I see anything. Link to comment Share on other sites More sharing options...
abtrapp Posted June 1, 2011 Author Share Posted June 1, 2011 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 More sharing options...
Portlight Posted June 1, 2011 Share Posted June 1, 2011 you need to try changing your resetType in your code - are you not pulling data from a database? Link to comment Share on other sites More sharing options...
abtrapp Posted June 2, 2011 Author Share Posted June 2, 2011 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 More sharing options...
siebe.vos Posted December 17, 2013 Share Posted December 17, 2013 + 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 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