File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes NX: Update owner in JTable 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 "NX: Update owner in JTable" Watch "NX: Update owner in JTable" New topic
Author

NX: Update owner in JTable

Maria Lepschy
Ranch Hand

Joined: Jan 12, 2004
Posts: 78
Hi all,
For booking, I update directly the field owner in the JTable. The problem is, that JTable gets the value of the editing cell only if the return key is pressed. To avoid this(the cell value should be taking immediately by pressing the button "Book")I wrote when the button is pressed following code:
TableCellEditor defaultEditor =_table.getDefaultEditor(tableMode.getColumnClass(5));
defaultEditor.stopCellEditing();
The problem is that this is not working for the first time that I tried to update the owner field equal which row I selected. After this, it works on all records.
Any ideas how I can correct this?
Regards,
Maria
Maria Lepschy
Ranch Hand

Joined: Jan 12, 2004
Posts: 78
Ok, it works if I add a FocusListener on my table.
But I changed my design and I entered the owner in a separate text field.
Now I have another question. In my instructions stays about the owner:
"The id value (an 8 digit number) of the customer who has booked this".
That means that the owner length must be exactly 8, or?
It should be possible to rebook one record?
Regards,
Maria
Satish Avadhanam
Ranch Hand

Joined: Aug 12, 2003
Posts: 697
Hi Maria,
Originally posted by Maria Lepschy:
Ok, it works if I add a FocusListener on my table.
But I changed my design and I entered the owner in a separate text field.
Now I have another question. In my instructions stays about the owner:
"The id value (an 8 digit number) of the customer who has booked this".
That means that the owner length must be exactly 8, or?

I understood in this way. It is an 8 digit number represented in text format(i.e. String). It can be between 1 to 8 digits and cannot be more than 8 digits.

It should be possible to rebook one record?

You can allow to rebook or not. If you do or don't you have to document it accordingly.

Regards,
Maria

Hope this helps.
Xie Ruchang
Ranch Hand

Joined: Dec 25, 2003
Posts: 160
Hi Maria
Have you considered while an user (User A) is booking for a room, another user (User B) is suceeded before User A? May I suggest you populate the JTable with the information from the database instead of using the value from the UI.
Best Regards
Maria Lepschy
Ranch Hand

Joined: Jan 12, 2004
Posts: 78
Hi Satish, Frankie,
Thanks a lot.
Satish, you mean the length of owner field can be less than 8?
Frankie, I don'understand your answer very well. I populate my table from the database. I have only one screen with my table, the owner field and the 2 search criteria fields. If I want to book a record, I selected the row, fill the owner field. If I press book the value from the owner field is saved in the db file and is taken into the owner column from the selected row. So my table is always populated with the values from db file.
Regards,
Maria
Xie Ruchang
Ranch Hand

Joined: Dec 25, 2003
Posts: 160
Hi Maria,
Then it is OK, sorry that I have misread you.
Best Regards,
Satish Avadhanam
Ranch Hand

Joined: Aug 12, 2003
Posts: 697
Hi Maria,
Originally posted by Maria Lepschy:
Hi Satish, Frankie,
Thanks a lot.
Satish, you mean the length of owner field can be less than 8?

Yes. But to make life easy, we can allow only 8 digit numbers in the owner field and document it as the requirement that owner field is EXACTLY 8 digits and not less or more So if the customer number is say 150, CSR MUST enter 00000150.

Frankie, I don'understand your answer very well. I populate my table from the database. I have only one screen with my table, the owner field and the 2 search criteria fields. If I want to book a record, I selected the row, fill the owner field. If I press book the value from the owner field is saved in the db file and is taken into the owner column from the selected row. So my table is always populated with the values from db file.
Regards,
Maria

Hope this helps.
Maria Lepschy
Ranch Hand

Joined: Jan 12, 2004
Posts: 78
Hi Satish, Frankie
Many thanks for your answer. Satish, this is a very good idea.
Regards,
Maria
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: NX: Update owner in JTable
 
Similar Threads
JTable input not correctly input-ted when a button is pressed
JTable
NX: How to get the new value from the cell of the JTable ?
Accepting text in JTable
JTable