Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

dataTable and repeatitive data

 
shilan kalhor
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all

i'm using jsf and datatable for displaying,deleting and editing result of a query
the problem is when i try to assign the value of the datatable to a Result Object, everything

goes right but as i try to assign a ArrayListDataModel or ListDataModel. it only displays the

last record of my table and it repeat it according to the table records count!
i'm really confused since i've printed the value of the model for different indexes and they are

different! but when it comes to display the data on the datatable, it shows the last record only

repeatedly

is it something wrong with dataTable or something?


thanks in advance
shilan
 
Stefan Evans
Bartender
Posts: 1713
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Before pointing the finger at datatable, I would first question the validity of the List.
It is quite possible that the records in the List ARE all the same values.

There is a common error in coding, when looping through an adding items to a list - you need to create a new instance for every item in the list.
Incorrect code:


Correct code:



Cheers,
evnafets
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic