wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes How to save a table model to a database and how do you know it is dirty? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How to save a table model to a database and how do you know it is dirty?" Watch "How to save a table model to a database and how do you know it is dirty?" New topic
Author

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

Jacky Luk
Ranch Hand

Joined: Aug 02, 2012
Posts: 580
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

Joined: Oct 16, 2003
Posts: 1075
    
  10

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.


Ranga.
SCJP 1.4, OCMJEA/SCEA 5.0.
Jacky Luk
Ranch Hand

Joined: Aug 02, 2012
Posts: 580
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

Joined: Aug 02, 2012
Posts: 580
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

Joined: Oct 16, 2003
Posts: 1075
    
  10

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

Joined: Aug 02, 2012
Posts: 580
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

Joined: Oct 16, 2003
Posts: 1075
    
  10

Ok, then you need to provide code for us in the form of SSCCE which reproduces the problem.
Jacky Luk
Ranch Hand

Joined: Aug 02, 2012
Posts: 580
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

Joined: Oct 27, 2005
Posts: 19543
    
  16

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.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to save a table model to a database and how do you know it is dirty?
 
Similar Threads
Accepting text in JTable
Using a the selected JTable name
JTable, reloading the table...
how to work with Table Model?
Unknown number of rows to create a JTable