Two Laptop Bag*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes How to get the recNo from client's record displaying talbe? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "How to get the recNo from client Watch "How to get the recNo from client New topic
Author

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

Zhixiong Pan
Ranch Hand

Joined: Jan 25, 2006
Posts: 239
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.


SCJP 1.4 SCJD
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
Where are the record numbers on your client side?


Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
Leo Ho
Ranch Hand

Joined: Mar 31, 2005
Posts: 36
Hi Pan, how about this:
jTable.getModel().getValueAt(selectedRowIndex, REC_NO_COLUMN);

Leo
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
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

Joined: Aug 17, 2005
Posts: 215

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..


Bob N
SCJP - 1.4
SCJD - (B&S) Used 1.5 And It Runs On Solaris10
SCWCD - Thanks to HFSJ!!
Zhixiong Pan
Ranch Hand

Joined: Jan 25, 2006
Posts: 239
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

Joined: Apr 21, 2006
Posts: 1847
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).


42
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to get the recNo from client's record displaying talbe?
 
Similar Threads
getting table row number when link is clicked question
how to know which record to update?
(URLyBird)How to mark a record to deleted one?
JTable auto select row
Maintain checked and unchecked in checkbox in pagination in display tag in struts