File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Room ID in JTable

 
Anonymous
Ranch Hand
Posts: 18944
  • 0
  • send pies
  • Quote
  • Report post to moderator
Hi all,
There has been a lot of discussion concerning the primary key issue in the URLyBird assignment. I've decided to make rowID my primary key.
Outside the DataAdapter/DataFacade class rowID is irrelevant because I use a Room value object (see this topic) with a primaryKey attribute. So, the Room simply knows it's got a primary key, but it doesn't know that its value is a rowID.
The client displays Room objects in a JTable and my TableModel, thus, stores a List of Room objects.
Ok, that is context... here comes the question:
Is there any other way of retrieving the primary key of a selected room other than making the key a hidden table column? This would be almost as ugly as displaying the primary key as a regular column...
I thought about a tableRowIndex/primaryKey mapping, but since my table model is sortable this would only complicate matters.
If you've got a hint (or two cents as ranchers like to say ) please let me know.
Regards,
Marcel
[ April 26, 2004: Message edited by: Marcel St�r ]
 
Anonymous
Ranch Hand
Posts: 18944
  • 0
  • send pies
  • Quote
  • Report post to moderator
Hhmmm, maybe I should rephrase my question?
How do you store the reference to the roomID which is needed for the booking on the client side?
I still don't see any other solution than the "hidden column" hack...
Regards,
Marcel
 
Denis Spirin
Ranch Hand
Posts: 72
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Marcel
I did that as follows:
1. Model gets data as Vector. Each element is array containing its ID.
2. Model copies data into two-dimensional array without primary key.
Thus we have one-to-one relationship between row number in array and element
position in Vector.
If you want to let user to sort table, you just sort data (with keys), copy them to Vector (with keys) and then to 2d array (without keys).
Regards
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic