Jump to content

Collection not being grouped !


Recommended Posts

By: msprasanth - msprasanth

Collection not being grouped !

2006-03-01 10:26

Hai,

 

I pass in a collection of objects as a datasource. I added a group to break on a field 'Year' of the collection, which means, a new group for each Year.

 

If the collection contains 4 records for 2003 and 3 records for 2004, then two groups are printed out with only 1 record from each year !!

 

Any suggestions please ?

 

Thank you.

 

 

 

 

By: msprasanth - msprasanth

RE: Collection not being grouped !

2006-03-01 12:10

I did sort the collection on 'Year' property.

 

 

 

 

By: msprasanth - msprasanth

RE: Collection not being grouped !

2006-03-01 12:14

If i give the groupExpression like $V{REPORT_COUNT} it displays all records ofcourse again 1 record per group, but if i change it to $F{field6}, it prints only two groups one for 2003 and one for 2004 with only one record in each group !! I wonder whats wrong !!

 

 

 

 

By: msprasanth - msprasanth

RE: Collection not being grouped !

2006-03-02 08:16

any help pleaase ?

 

 

 

 

By: sunlight - foundnothing

RE: Collection not being grouped !

2006-03-02 22:05

I have some question when I set the JavaBeans as the DataSource

maybe I should describe the question as following:

(1)firstly,I will instruct the process how I did it.

I construct two class(Person and Factory) like this,

 

public class Person {

private String name = "";

private int age = 0;

public Person(String name,int age) {

this.name = name;

this.age = age;

}

public String getName(){

return name;

}

public int getAge(){

return age;

}

}

 

 

import java.util.Vector;

import java.util.Collection;

public class Factory {

public static Collection generateCollection(){

Vector collection = new Vector();

Person p;

try{

p = new Person("Tom",20);

collection.add(p);

p = new Person("Found",26);

collection.add(p);

p = new Person("Lucy",18);

collection.add(p);

p = new Person("Jame",35);

collection.add(p);

p = new Person("Smith",42);

collection.add(p);

}

catch(Exception e){

}

return collection;

}

}

 

(2)secondly,I use the command of javac to assemble Factory Class

as follows:

javac Factory.java

 

(3)then,I set up the Ireport classpath c:Ireportclasses which contains the two class

 

files

Factory.class and person.class

 

(4)I open the item Datasource in the menu of Ireport and choose JavaBeans set Datasource,

Name:JavaBeans

Factory Class:Factory

static method:generateCollection

and I select the radio Collection of javaBeans.

(5)I test the connection but it tell me Exception Null??? I don't know why???

(6)I registe the fileds name and age in the frame of Fields and

set name's type as String,age Integer.

(7)I open a new document and put two fileds. one is $F{name} and the other is $F{age},then

 

I open the query widown and click the JavaBean Datasource,set class name as

Factory,then I click Read javabeans attributes,but the filed name and age vanish

instancely,and it display the filed name as class,the field type as java.lang.object

but why???? maybe it's leaded by the Exception in(5)????but who can tell me the reason???

(8)I run the report,and it never throw an Exception ,but it displayed nothing except.

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