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 Booking method in Facade / GUI. 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 "Booking method in Facade / GUI." Watch "Booking method in Facade / GUI." New topic
Author

Booking method in Facade / GUI.

Chiji Nwankwo
Ranch Hand

Joined: Jun 21, 2002
Posts: 56
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


SCJP, SCJD, SCWCD<br />"Meekness is not weakness, but power under control"
Eduard Jodas
Ranch Hand

Joined: May 14, 2002
Posts: 80

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

Joined: May 14, 2002
Posts: 80
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

Joined: Jun 21, 2002
Posts: 56

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

Joined: Jun 20, 2002
Posts: 51
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

Joined: May 14, 2002
Posts: 80
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

Joined: Jun 20, 2002
Posts: 51
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?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Booking method in Facade / GUI.