• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Updating Available seats value in datainfo

 
Ranch Hand
Posts: 360
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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;

}
 
Ranch Hand
Posts: 688
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dilipkumar:
I don't think you need to update the available seats. As least it's not in my requirement.
 
Dilip kumar
Ranch Hand
Posts: 360
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 688
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 318
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 360
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 688
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 360
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks,
I was talking about point #1 in David's reply.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
reply
    Bookmark Topic Watch Topic
  • New Topic