itchytoes Posted August 15, 2007 Share Posted August 15, 2007 I have a <variable> as follows: <variable name="YearsList" class="java.util.List" resetType="Group" resetGroup="AsmGroup" calculation="Nothing"> <initialValueExpression><![CDATA[new ArrayList()]]> </initialValueExpression> </variable> This is driving me nuts, but the List is being initialized more often than it should. I know that the AsmGroup has not changed, but I end up getting a new empty ArrayList when I should not be. Am I doing something dumb? Betty Link to comment Share on other sites More sharing options...
codyjasperForge Posted August 15, 2007 Share Posted August 15, 2007 How is it that you know that the 'List' is being initialized? By default a List is initialized to all null -OR- 0 values. (Depending on what type of list you are creating) 'ints' get initialized to 0 (zero) 'Strings' get initialized to null -OR- " " (same thing) what are you using for the variable expression? Link to comment Share on other sites More sharing options...
itchytoes Posted August 15, 2007 Author Share Posted August 15, 2007 Hi -- thanks for responding. My YearsList variable is actually being filled elsewhere. I do not have <variableExpression> specified. I'm not using this for a table of contents, but it is similar to the table of contents example in that I am adding entries to my list elsewhere via a scriptlet. So, in my scriptlet code, I did a System.out.println to display the size() of my list, and it becomes zero too often, indicating that it must have been re-initialized. I changed the resetType to Report just for kicks to see what happens, and in that case the List size does grow over time without being reset. However, I really do wish to reset it with this particular group. I am using jasperreports 1.3.4. Link to comment Share on other sites More sharing options...
codyjasperForge Posted August 15, 2007 Share Posted August 15, 2007 However, I really do wish to reset it with this particular group. You should be able to reset on a group. What matters most is the group expression though. Have you tried altering the group expression so that it might not change so often? From the sounds of it, this is source of the re-initialization. I would suggest maybe changing the group expression to a value that will not change as often. You could even create a variable and use it's reset type inside the group expression. This is very intriguing. Hope it helps some. Link to comment Share on other sites More sharing options...
itchytoes Posted August 15, 2007 Author Share Posted August 15, 2007 Hi - Woohoo! I sorted out my problem. My report has two groups. The group that adds to my YearsList variable is an "inner" group relative to the AsmGroup which is used to reset the variable. However, in my report, I had erroneously specified the <group> for the inner group BEFORE the specification of the outer AsmGroup. In all my other reports, I've been specifying groups going from outer to inner in sequence, but somehow I got this one backwards. As a result, I guess the AsmGroup ends up being restarted a lot or something. Betty Link to comment Share on other sites More sharing options...
codyjasperForge Posted August 15, 2007 Share Posted August 15, 2007 Glad you figured it out...Good luck ;) 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