Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to update the different client windows?

 
Bably Das
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,

My problem is that I start the server and two client windows simultaneously. So in one client window I select a room and click the book button to book that room. The customer Id entry dialog is then displayed and I enter a 8 digit number to book that room.

In the second opened client window I do the same, that is, book the same room but with a different customer Id. Right now when I click the "Book" button in the second client window, the customer id entry dialog is displayed and when I enter a different 8 digit customer id, my JTable is refreshed with the old value of the customer Id as I entered in the first opened client window for that room. So my questions are:

1. Once the room is booked in the first client window how do I refresh the JTable data in the other opened client windows?

2. Where do I need to throw the RoomAlreadyBookedException and an error message to notify the second client that the room he/she is trying to book is already booked by the first client?

3. If the value of the customerId stays as entered by the first client for n number of clients, is my locking method working as expected?

Many thanks,
Bably Das
 
Roel De Nijs
Sheriff
Posts: 9933
113
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bably,

1/ there is no requirement which requires data refreshing in different client windows, so I would not implement that (refresh of data occurs when user hits search button).
2/ I throw that kind of exception in my business service and it's caught in my client (where I show an appropriate message).
3/ I don't think this behavior is related to the locking method. It means your business logic to check if the room is already booked is working. The lock method of the Data class has another purpose which is described excellently in the ScjdFaq.

Kind regards,
Roel
 
Bably Das
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Roel for your quick reply.
I am completely happy with the 1st and the 2nd points you mentioned and have implemented them. But unsure about the third. I have gone thru the link you provided.

3/ I don't think this behavior is related to the locking method. It means your business logic to check if the room is already booked is working. The lock method of the Data class has another purpose which is described excellently in the ScjdFaq.


My book method does lock -> update -> unlock. Just wanted to confirm that if my lock method is working as per Roberto's lock test class, is it a certainty that my locking and unlocking mechanism are working as desired?

Thanks,
Bably Das
 
Roel De Nijs
Sheriff
Posts: 9933
113
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you can run Roberto's test case multiple times (incrementing the loop counter each time) without your application "hanging" for ever (that's a deadlock), your locking meachnism is just fine.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic