Hello, great people!
Assume there is a healthcare application, It is admin/Doctor's task to choose the available time slots out of total slots for the day. He selects the slots and clicks on save button. These time slots have to be stored into 'available-slots' table in the db.
Now I want to know what is the way to send all these time slots from client-side to the Server/backend in one go?
Will they all be sent as array of object?
How will they be extracted at backend once received?
If there are 30 slots to be stored, will there 30 queries be fired to insert each time slot?
How would you do this if you had to build this application? I will be grateful to you if you could help me giving an idea about it.
If the data become available all at once, I would send one request, in order to cut down on network overhead. That might not matter much if client and server are on the same network, though - are they?
I would make them checkboxes, styled with CSS to look like blocks. Then let the form do all the work of sending the values to the backend just as checkbox groups usually are (each with the same name and assembled by the servlet container¹ into an array).
¹ Assumes a Java backend; but as this was originally posted in an EJB forum, Java seems to be a given.
Unless only one can be chosen, and then I'd use radio buttons in the same way. But then, there's no question about multiple values, so...
Your description of the problem, and the screen capture you show don't really line up. Your problem description says the user is a doctor, but the figure shows how a patient selects a single time slot. I assume it was just an example of how you want the slots to appear on the form?
The picture shows the view of patient's side, I apologise for the confusion, I just wanted to show the 'multiple time-slots'. The same type of slots will appear on the screen of Admin.
So please consider just the time-slots, not 'book an appointment' button n other view.