Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Booking method in Facade / GUI.

 
Chiji Nwankwo
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have a booking method in my client side facade. When the client enters the number of seats required for the booking and clicks the continue button, i present the user with a dialog box which contains the flight information including the requested number seats. I only call the booking method in my facade when the user clicks the book button in the dialog box. Clicking this button closes the dialog box and displays a status message at the bottom of the original screen. This message is displayed for as long as the booking takes.
My questions are as follows:
1. Should I prevent the user from performing any other searches until the booking is confirmed?
2. Should I allow the user to continue performing searches, eventhough the previous search has not completed?
I create a new thread for the application to perform the processing of the booking, which could be delayed if other clients have locks on the same record or are waiting to obtain the lock on the record. I am also using the SwingUtilities.invokeLater() method to update the status message displayed at the bottom of the screen.
I hope all this makes sense, please comment.
Regards,
Chiji
 
Eduard Jodas
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

2. Should I allow the user to continue performing searches, eventhough the previous search has not completed?

How many panels do you have to show the results?
If you only have one, how can the user know if the currenly displayed results are from one search or another? Being multithreaded you can't asure which search will finish first.
It could be useful to allow the user to cancel the current search that is taking too long in order to perform another search.
Anyway, I don't think all this multithreading is necessary to get more points. It can only give you some headaches.
 
Eduard Jodas
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I use multithreading only to prevent the GUI from freezing while waiting for the server to finish the search/book.
At the same time I block the GUI so there can only be two threads: the event dispatch thread, which repaints the GUI, and the search/book thread.
 
Chiji Nwankwo
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

How many panels do you have to show the results?

I have a frame which contains a results section that contains my jtable with the results. when the user clicks on the record they are interested in, enter the number of seats they require and click a continue button, I present them with a dialog that displays their selection and number of seats. this dialog contains a book button on it. I might be able to disable a record until the booking finishes and not let the user perform any more booking on that particular record or anymore searches.

At the same time I block the GUI so there can only be two threads: the event dispatch thread, which repaints the GUI, and the search/book thread.

How are are able to restrict the number of threads available?
Thanks for your comments.
Chiji
 
Gosling Gong
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Eduard Jodas:
I use multithreading only to prevent the GUI from freezing while waiting for the server to finish the search/book.
At the same time I block the GUI so there can only be two threads: the event dispatch thread, which repaints the GUI, and the search/book thread.

Eduard, if you use another thread to do the searching after user clicking the search button, how can you prevent user from click the search button before the previous searching is not finished?
 
Eduard Jodas
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The easiest way is showing a popup dialog saying for example "Search in progresss ..."
The easy way is disabling the search button before starting the thread. However, that doesn't prevent the user from clicking the exit button or another, although those buttons can also be disabled.
The tricky way is displaying a transparent panel on top of the frame (through the frame's JLayeredPane). Being transparent the user is not aware of this panel. This panel has the mousevents and keyevents enabled in order to consume() them and not allowing them to reach the underlaying components. Furthermore the Frame FocusManager must give the focus to this pane and prevent it from losing the focus via use keystrokes or application's requestFocus()/transferFocus(). Finally, the pane's cursor must be set to WAINTING_CURSOR (a clock mouse pointer) so that the user knows the application is busy.
I'm still working on the third way.
 
Gosling Gong
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
regarding the booking methods, did you take the number of ticket as one parameter, or you modify the DataInfo directly in the booking dialog?
saying when user click OK in your dialog, do you modify the DataInfo and then transfer to the method in the facade, or pass the original DataInfo and the number of tickets to it?
another question is, do you modify the method modify(DataInfo newData) in Data class?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic