• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

NX: Update owner in JTable

 
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 697
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 160
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Maria,
Then it is OK, sorry that I have misread you.
Best Regards,
 
Satish Avadhanam
Ranch Hand
Posts: 697
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Satish, Frankie
Many thanks for your answer. Satish, this is a very good idea.
Regards,
Maria
 
He puts the "turd" in "saturday". Speaking of which, have you smelled this tiny ad?
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic