Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem in using setValueAt() method - AbstractTableMethod.class

 
Velika Srbija
Ranch Hand
Posts: 172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've made my own implementation of setValueAt and isCellEditable methods (as well as other ones) in my TBLModel class that extends AbstracttableModel class.
Here are brief descriptions of the methods:
ResultSetMetaData metaData;
...
...
public boolean isCellEditable(int row, int col) {
if (metaData.getColumnName(col+1).equals("ID")) return false;
else return true;
}
public void setValueAt(Object value, int row, int col) {
int price = 0;
int id = 0;
...
//making changes in my data model - inserting new value in my row_vector etc.
...
...
//all of above code works fine
//
//problem begins here - when I try to update my hsql database
//example:
int no_update = statement.executeUpdate("update first_table set price="+price+" where ID="+id);
}
The problem with the above code is that after executing of setValueAt method, runtime calls isCellEditable method again. When it comes to the if statement java.lang.NullpointerException gets fired (though metadata is not null).
Note: If I remove the code in setValueAt method that updates my database, everything works OK. No Exceptions occures.
What is goin' on?
Why is method isCellEditable called again after executing of setValueAt method?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic