Jump to content

Recommended Posts

By: Ilievski Bozidar - bobi1978

GroupCount ?

2002-02-03 14:50

Hi Teodor.

 

I need to have a variable (something like PAGECOUNT)

that will count how many groups I have in a report,(when I use <group> tag).

And I need to print that number, every time new

group apperas in a report.

Any help...

 

 

 

 

 

By: Teodor Danciu - teodord

RE: GroupCount ?

2002-02-03 23:50

 

Hi,

 

There is no simple way to do that right now.

It will be when scriptlets will be available.

 

I suggest you try something like this:

 

Define a variable that re-initializes itself every time your group changes

(see "resetGroup attribute").

On the "initialValueExpression" of this variable (which will be evaluated every time

you group changes), put an expression that calls a static method in a class somewhere,

that will increment a static member representing your group count.

Using another defined variable that reads this static group count,

you will be able to display it on your report.

 

I think this should work. In the report expressions, you can access your own

libraries if they are visible in the classpath.

 

Good luck!

Teodor

 

 

 

By: Teodor Danciu - teodord

Group number solution

2002-02-20 23:47

 

Hi,

 

I was wrong when I told you there is

no simple way to do that.

In fact is very simple:

 

Lets say you have a group called "CityGroup"

on your report and you want to have a variable

that increments itself every time the City changes.

Then you could define a variable called

"CityNo" like this:

 

<variable name="CityNo" class="java.lang.Integer" resetType="Group" resetGroup="CityGroup" calculation="System">

<variableExpression/>

<initialValueExpression>

($V{CityNo} != null)?(new Integer($V{CityNo}.intValue() + 1)):(new Integer(1))

</initialValueExpression>

</variable>

 

You can see that this variable has only an

initial value expression that is evaluated every

time the "CityGroup" changes and it increments itself.

I order to be able to benefit from the initial

value expression functionality you have to

specify that your variable perform some kind

of custom calculation (calculation="System").

 

I think I'll put this on the "Tips & Tricks" section.

 

Good luck!

Teodor

Link to comment
Share on other sites

  • 6 months later...
  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

But how does it looks when I have a say StateGroup into which CityGroup is embedded :(

 

How would you then implement the counter :unsure:

 

The CityNo should always start from the begin with each new state.

 

Any hints?

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