Jump to content
Changes to the Jaspersoft community edition download ×

Initial Value Expression for variables


Recommended Posts

By: chandan - chandan_000

Initial Value Expression for variables

2006-03-03 02:51

Using iReport-1.1.0, I created a report that contains a field together with a custom variable(named RowCount) in the detail band.

 

My idea is to print the serial number(determined by RowCount) of rows for each of the fields encountered.

 

My problem is - How can I make the RowCount start from (say) 5 onwards. I made use of the Initial value expression for the variable, but it does not seem to be working.

 

Details of variable RowCount:

 

Variable name: RowCount

Variable class type: java.lang.Integer

Calculation type: Count

Reset Type: Report

Increment Type: None

Variable expression: $V{RowCount}

Initial value expression: new Integer(5)

No Custom Increment Factory class.

 

Plz help me on this.

Thank you.

 

 

By: Lucian Chirita - lucianc

RE: Initial Value Expression for variables

2006-03-06 01:40

The initial value expression is used to provide the variable a value used before it first gets incremented. It is not used as a first or base value value when incrementing the variable.

 

What you can do is to create another variable that evaluates to RowCount + 5 and use it in your report.

 

Also, using $V{RowCount} as the expression for the RowCount variable seems a little weird, you might want to revise that.

 

HTH,

Lucian

 

 

By: chandan - chandan_000

RE: Initial Value Expression for variables

2006-03-07 01:13

Yes, the idea of using yet another variable that evaluates to RowCount+5 is fine. But I got it solved my own way. The changes I made to the above variable details are:

 

Variable name: RowCount

Variable class type: java.lang.Integer

Calculation type: Nothing

Reset Type: Report

Increment Type: None

Variable expression: new Integer($V{RowCount}.intValue() + 1)

Initial value expression: new Integer(5)

No Custom Increment Factory class.

 

Here I did use $V{RowCount} in the variable expression. Let me know if it's not a good practice to use it this way.

 

Thank You.

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

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