aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes how to know which record to update? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "how to know which record to update?" Watch "how to know which record to update?" New topic
Author

how to know which record to update?

Jason Hocker
Ranch Hand

Joined: Jul 23, 2003
Posts: 132
How do I know what record to update? Yes, I realize this depends on how I design everything else. I'm using an algorithm based on position in the file for the recNo. I read strings out of the file, and populate the table model. Right now I am not putting the recNo as a column in the table model. My GUI uses a text box to get the customer number, and based on the line in the JTable that is highlighted, will want to update the database file that the record is now reserved. But I lost the recNo to use. I thought about building a map of JTable row to database recNo, but then wasn't sure how to keep that updated if I allow the columns to be sorted. Could be cheap and remove column sorting. Or I could add recNo as a column in the JTable, and use that, sorta like how the upc value is used in the "Denny DVD" example.

Can anyone provide any thoughts?
Muhammad Shafique
Ranch Hand

Joined: Sep 30, 2006
Posts: 59
It's better to have record number on client side. It saves from lot of work. Using JTable row number may not be a good idea. You could manage row number in sorting but what if some user deletes a record? Add a hidden column for record number in data display table.


Shafique
Jason Hocker
Ranch Hand

Joined: Jul 23, 2003
Posts: 132
I looked for how to hide a column, but could not see a good way. Would you be able to provide an example? Thanks!
Rodrigo W Bonatto
Ranch Hand

Joined: Aug 20, 2004
Posts: 62
You can remove a JTable column without removing data from model using the following method:

public void removeColumn(TableColumn aColumn)

Regards,


SCJA, SCJP, SCJD, SCWCD, SCBCD5, SCDJWS, SCEA5
Jason Hocker
Ranch Hand

Joined: Jul 23, 2003
Posts: 132
I dont know how I missed that. I didnt know how the TableColumn class and others. Thanks!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to know which record to update?