views:

41

answers:

1

I am using Entity bean in NetBeans, to develop some master/detail forms. When I run the forms, I click the Delete JButton, and the row dissapears from the JTable.

But when I click on "Reload", the supposedly deleted row shows up again. I don't know why is this happening; why does the Entity doesn't erase all the way to the database table, and just deletes it out of the JTable?

A: 

This sort of issue sounds like it's related to the separation of the data (the model) from the view. I don't have specific knowledge regarding your technologies used, but hopefully I can provide some insight into what is the root of your problem.

In your case, it sounds like when you "Delete" you're only removing it from the view; you're not actually manipulating the data in any way (i.e. the model is not aware of this deletion).

Therefore once you "Reload" - which usually means that the view asks the model for what data to present - your "deletion" is lost since the model hasn't changed at all, and thus provides the exact same data to the view.

This sort of behavior is likely to occur when you're manipulating the data (i.e. deleting things) via the JTree itself or even the contained TreeNode objects, rather than the underlying TreeModel.

Hopefully this information helps you, sorry I don't have a more specific answer.

Shakedown