populating table with initial data:
additionsTable.setModel(new AdditionalDocsTableModel(addDocuments));
constructor of the model:
public AdditionalDocsTableModel(List<MyDocument> docs) {
this.docs = docs;
}
Here’s code in AbstractTableModel for deleting object from table:
public void delObjectAtRow(int row){
MyDocument doc= docs.get(row);
MainFrame.session.beginTransaction();
MainFrame.session.update(doc);
MainFrame.session.delete(doc);
MainFrame.session.beginTransaction().commit();
}
calling method:
private void deletePopupItemActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if (additionsTable.getSelectedRow() > -1) {
AdditionalDocsTableModel t = (AdditionalDocsTableModel) additionsTable.getModel();
t.delObjectAtRow(additionsTable.getSelectedRow());
}
}
How do i populate model with new data ? Right now i cant retrieve new data from session. i tried load and update. but receive same stuff as before deleting. Any help would be appreciated. thanks in advance!
You need to call one of the fire methods of the base class to notify JTable that the data has changed.