• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to save a table model to a database and how do you know it is dirty?

 
Jacky Luk
Ranch Hand
Posts: 634
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Changed my mind.
How would I do these things?
1) save a table model into the database after clicking on a button
2) how do you know that the table model is dirty? (has been changed)
Thanks
Jack
 
Ranganathan Kaliyur Mannar
Bartender
Posts: 1101
10
Java Netbeans IDE Ubuntu
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jack Luk wrote:How would I do these things?
1) save a table model into the database after clicking on a button

Well, you know your model. So, read through the model (say iterate) and make JDBC calls to take appropriate action.

Jack Luk wrote: 2) how do you know that the table model is dirty? (has been changed)

You need to listen to table model changes via TableModelListener.
 
Jacky Luk
Ranch Hand
Posts: 634
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ranganathan Kaliyur Mannar wrote:
Jack Luk wrote:How would I do these things?
1) save a table model into the database after clicking on a button

Well, you know your model. So, read through the model (say iterate) and make JDBC calls to take appropriate action.

Jack Luk wrote: 2) how do you know that the table model is dirty? (has been changed)

You need to listen to table model changes via TableModelListener.


One thingy strange is that when I follow this sample


I set a bp inside tableChanged, my Event handler bp was never hit.
I will prepare another test set tomorrow.
Thanks
Jack
 
Jacky Luk
Ranch Hand
Posts: 634
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
https://docs.google.com/open?id=0Byu1vVqeMEJ5NjF1OG9uLUdRLWM

You'll notice that valueChanged occurs before I make changes to the cell
in another way, if I use tablelistener, the tableChanged event was never triggered

Thanks
Jack
 
Ranganathan Kaliyur Mannar
Bartender
Posts: 1101
10
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jack Luk wrote:I set a bp inside tableChanged, my Event handler bp was never hit.

I have no idea what 'bp' means. Can you explain?
 
Jacky Luk
Ranch Hand
Posts: 634
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ranganathan Kaliyur Mannar wrote:
Jack Luk wrote:I set a bp inside tableChanged, my Event handler bp was never hit.

I have no idea what 'bp' means. Can you explain?


bp == breakpoint. Sorry for the abbreviation
Thanks
Jack
 
Ranganathan Kaliyur Mannar
Bartender
Posts: 1101
10
Java Netbeans IDE Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, then you need to provide code for us in the form of SSCCE which reproduces the problem.
 
Jacky Luk
Ranch Hand
Posts: 634
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ranganathan Kaliyur Mannar wrote:Ok, then you need to provide code for us in the form of SSCCE which reproduces the problem.


https://docs.google.com/open?id=0Byu1vVqeMEJ5bm1TSFFCQUJJTFk

The source code has been reduced to a only a few methods. about 54K, in which 30K is the form and inevitable
Let me know
Thanks
Jack
 
Rob Spoor
Sheriff
Pie
Posts: 20659
64
Chrome Eclipse IDE Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
54K is not a short self contained, correct example. And with all the separate files I'm not sure I would call it self contained either.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic