• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Table Resetting data problem

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
I have a JTable with DefaultTableModel as model.
When I first populate table with data(from database), I am storing the table data locally in a vector, using
Vector cols; //this is initialized with column names.
Vector data = ((DefaultTableModel)table.getModel()).getDataVector();

This table is editable, when user changes data and hits save, if any problem occurs while saving, I want to reset table data to previous values . So, I am trying to reset table data as below.
((DefaultTableModel)table.getModel()).setDataVector(data, cols);
But it does't work, the vector data now has the current values that user has modified to, not the previously stored values.

I also tried to store data by doing a copy of the data as below,

Vector tempV;
tempV = ((DefaultTableModel)table.getModel()).getDataVector();
Object [] tempAr = new Object[tempV.size()];
tempV.copyInto(tempAr);
vector= new Vector(Arrays.asList(tempAr));

Even then it has the current value.
Appreciate if anybody can help ...
Thanks in advance.
-Ssh
[ January 23, 2002: Message edited by: Seema Hanji ]
 
Willie Smits can speak 40 languages. This tiny ad can speak only one:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic