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 Updating Available seats value in datainfo 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 "Updating Available seats value in datainfo" Watch "Updating Available seats value in datainfo" New topic
Author

Updating Available seats value in datainfo

Dilip kumar
Ranch Hand

Joined: Oct 16, 2000
Posts: 360
Hi,
When user selects the row in Jtable I'm updating
variable "rowSelected". When user clicks on "Book
Tickets" button I'm
displaying input dialog box to accept No. of seats. I have data for
record selected in datainfo variable. I'm not getting any ideas to
update "Available seats" value in datainfo variable with new
value
(Available seats - No. of tickets enter by user ). This datainfo
will
be passed to modify method in data class.
Which is the best place to update Available seats? Client or Server ?
Thanks
Dilip
public void actionPerformed(ActionEvent e) {
String seats = JOptionPane.showInputDialog
(frame, "Please enter number of tickets :");

// Update Seats Availabe for the record selected
datainfo = model.datainfoArray[rowSelected];

}
public void valueChanged(ListSelectionEvent e) {
if(e.getValueIsAdjusting()) return;
ListSelectionModel lsm = (ListSelectionModel)
e.getSource();
int selectedRow = lsm.getMinSelectionIndex();
rowSelected = selectedRow;

}
Adrian Yan
Ranch Hand

Joined: Oct 02, 2000
Posts: 688
Dilipkumar:
I don't think you need to update the available seats. As least it's not in my requirement.
Dilip kumar
Ranch Hand

Joined: Oct 16, 2000
Posts: 360
Don't we have to decrease the value of "Availabe seats" in db when we book tickets ?
Adrian,
I'm talking about point 4 in your Peudo code in the below thread http://www.javaranch.com/ubb/Forum25/HTML/000329.html
Thanks
Dilip
[This message has been edited by Dilipkumar Kalyankar (edited February 19, 2001).]
Adrian Yan
Ranch Hand

Joined: Oct 02, 2000
Posts: 688
Dilipkumar:
Sorry about the confusion.
Yes, there are several design you can choose from. Client or server side, after some thinking, I decided to put a book() method on my server side, it's just easier.
I'm still not quite sure as to exactly what your question is.
I'm gussing that you are trying to determine whether to put the booking on client or server. That's entirely up to you.
As far as decreasing the available seat, it should be done in your booking method.
As far as the updated seat available problem, my requirement specificly mention that need not to be implemented.
Matt DeLacey
Ranch Hand

Joined: Oct 12, 2000
Posts: 318
I don't understand exactly either, but one thing to keep in mind is you don't have to immediately refresh the views on all your clients when a booking is made. Obviously, the client who booked gets updated but others don't need to be updated until they try to book or they do a search (criteriaFind). At least, that's what my specs suggest. I don't think it's necessary to broadcast to all clients that an update has been made. Obviously, you update the database and you update the client that booked, but the others might contain stale data until they try to book or search. Of course, even if they have stale data (i.e. there is a field that SAYS there is a seat available when it isn't), if they request a book that SAYS there is a seat available when it is not, they do NOT successfully book a seat and you should tell them so.
With Respect,
Matt
Dilip kumar
Ranch Hand

Joined: Oct 16, 2000
Posts: 360
Matt, Adrian
Thank you very much. I got lot of information from you guys.
I think I haven�t put my initial question properly. For �modify� method in Data class I have to pass DataInfo argument. When I get �No. of seats� from user ( say for Flight number: SA001, Origin airport : SFO, Destination airport: DEN, Available seats: 50 ) do I need to create a new DataInfo with same values for all the fields except Available seats ( now Available seats = Available seats � No. of seats ) and pass it to �modify� method ?
Thanks
Dilip
Adrian Yan
Ranch Hand

Joined: Oct 02, 2000
Posts: 688
I still don't get your question. When a client books a flight, it passes the seats number(to book) to the book method, inside your book method, you have to read the record, modify it, then pass it to the modify method.
Is that what you to know?
Hope it helps.
davidlong
Greenhorn

Joined: Jan 28, 2001
Posts: 21
Dilipkumar
I am not quire sure what you really want to clarify about, so i just offer my solution here.
Booking methord:
1. modify DataInfo as;
valus[valus.length-1]= valus[valus.length-1]-bookedNumber;
2. modify db file by calling modify method;
3. after this, calling getRecord method to get the seat-changed Record for db file immediaterly, for later useing upgrading table display.
4. confirm to client booking secussed(dislog)
5. using new record to update table contents corresponding.
6. return void
Hope this will help your thoughts, welcome any comments of yours.
David
Dilip kumar
Ranch Hand

Joined: Oct 16, 2000
Posts: 360
Thanks,
I was talking about point #1 in David's reply.
Gary Milne
Greenhorn

Joined: Jun 15, 2001
Posts: 1
Originally posted by Dilipkumar Kalyankar:
Hi,
When user selects the row in Jtable I'm updating
variable "rowSelected". When user clicks on "Book
Tickets" button I'm
displaying input dialog box to accept No. of seats. I have data for
record selected in datainfo variable. I'm not getting any ideas to
update "Available seats" value in datainfo variable with new
value
(Available seats - No. of tickets enter by user ). This datainfo
will
be passed to modify method in data class.
Which is the best place to update Available seats? Client or Server ?
Thanks
Dilip
public void actionPerformed(ActionEvent e) {
String seats = JOptionPane.showInputDialog
(frame, "Please enter number of tickets :");

// Update Seats Availabe for the record selected
datainfo = model.datainfoArray[rowSelected];

}
public void valueChanged(ListSelectionEvent e) {
if(e.getValueIsAdjusting()) return;
ListSelectionModel lsm = (ListSelectionModel)
e.getSource();
int selectedRow = lsm.getMinSelectionIndex();
rowSelected = selectedRow;

}

Hi
I am looking for a java/corba application to book seats on
a bus to run on unix using the Orbacus v3.1.3 orb.
If you can give any help please reply
Gary
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Updating Available seats value in datainfo
 
Similar Threads
Help with getting the correct recnum for book seats method
question about the jcombox focus
Problem with JTable scrolling
lost focus in JTable
Jtable Event Handling