This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to get the recNo from client's record displaying talbe?

 
Zhixiong Pan
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi rancher,

In clients' displaying table, I can easily get the selected row number, but that number is not recNo which I need to pass into book(int recNo). How to transit selected row number to recNo? Thanks for your help.
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where are the record numbers on your client side?
 
Leo Ho
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Pan, how about this:
jTable.getModel().getValueAt(selectedRowIndex, REC_NO_COLUMN);

Leo
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Leo Ho:
Hi Pan, how about this:
jTable.getModel().getValueAt(selectedRowIndex, REC_NO_COLUMN);

Leo


That's why I asked the question. Are the record numbers stored in the table or somewhere else (if at all)?
 
Bob Nedwor
hangman
Ranch Hand
Posts: 215
Eclipse IDE Oracle Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tweaked the method in my remote interface (but not the method in the Data class) to also return the long recNo to the calling program along with all the other data. Because I am going to need the long recNo in case I want to lock, unlock, update, etc..
 
Zhixiong Pan
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

My present solution is like that: in HotelBusiness' search(String name, String city) method, I return a String[][] value named records = new String[v.size()][8]; v is an Vector object which stores the name and city exact matched records. Every record has 7 items and I want to let the recNo to be the 8th item. "String[][] records " will be passed to HotelRemote and finally to BusinessClient in client layer, and right there it will translate to a String[][] that will be passed into my AbstractTableModel's subclass.
 
Jeroen T Wenting
Ranch Hand
Posts: 1847
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
that's pretty much how I do it.
I've packed the data (including the record number) in a class with more natural names for the fields.
My TableModel just maps those fields to columns, and doesn't return the record number as the JTable has nothing to do with it.

I've added a method to the TableModel to retrieve that object complete (so including the record number) for passing to for example the booking dialog.

The search function returns from the database engine with a Map of string arrays using the record number as key (I wrapped the DB interface in another interface to achieve that effect, adding a few methods. That interface in turn is wrapped in another interface which adds the networking exceptions).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic