Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

How to update the different client windows?

 
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
 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • 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: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • 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.
 
Climb the rope! CLIMB THE ROPE! You too tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic