myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pawel.Czerwin...@anicasystem.com.pl
Subject Re: Index in tomahawk dynamic datatable
Date Thu, 06 Sep 2007 11:52:20 GMT
The problem is the way you create your list, which is:

> > >    public Proteins() {
> > >
> > >        Dataset set = new Dataset();
> > >
> > >        set.setName("Dataset 1");
> > >        set.setInput("This is Dataset 1");
> > >        list.add(set);
> > >
> > >        set.setName("Dataset 2");
> > >        set.setInput("This is Dataset 2");
> > >        list.add(set);
> > >    }

Please notice, that you've created only ONE Dataset object and you've just 
put it to the ArrayList multiple times.
But it is still the same object, so all list elements are the same, and 
have the same name (the name you've set last).
You need to create new instance of Dataset object for each row of a table, 
so your code should look like this:

public Proteins() {
        for (int i=1;i<=20;i++) {
                Dataset set = new Dataset(); // new instance of Dataset 
creation
                set.setName("This is Dataset " + (i+1));
                list.add(set);
        }
}



-- 
Regards
Paweł Czerwiński
pawel.czerwinski@anicasystem.com.pl



Wolfgang <wkluge@ebi.ac.uk> wrote on 2007-09-06 11:47:08:

> Hi Pawel,
> 
> ya you got me right, thx your solution works fine. But I have another 
> problem:
> If I create for example 4 new datasets and add them to the ArrayList, I 
> get in my result Table 4 lines that's correct,
> but only the name of the last added dataset is shown (so 4 times).
> 
> Do you know why?
> 
> Cheers Wolfgang
> >


Mime
View raw message