So now I am trying to use a ProgressIndicator.
(To review, the user clicks a Save button and I want to display a friendly notification, save changes to the database and close the application. Easy peasy, right? No…)
In the buttonClicked() method, I now:
- Make visible the (formerly invisible) progress indicator
- Show a friendly notification
- Start a thread to save changes to the database
- return
The notification is displayed as desired this time (yay!) because now I am returning quickly from the buttonClick() method allowing the browser to see the notification before the application closes.
The background thread then:
- Updates the database
- Occasionally updates the value of the progress indicator
- When the update is complete, it sets the value to 1.0
The last problem is to close the application.
I tried doing this in background thread. That didn’t work. So I tried putting a listener on the progress indicator, which tells me when the value I am setting changes and, specifically, when it reaches 1.0. When it does, I call application.close().
In either case (closing the application in the background thread or in the progress indicator listener), in the GUI, I get:
[b]
[color=#ff0000]
Session Expired
Take note of any unsaved data, and [u]
click here
[/u] to continue.
[/color]
[/b]
(So close and yet so far.)
It appears that the application.close() call is
immediately
expiring the session (even though we are in the middle of a browser-server-browser round-trip), and the browser detects this and displays the above Session Expired message. What I want it to do is to close the application and go to the logout page.
Without the background thread, I get to the logout page, but I do not get the notification message (because the notification message and the application close are being sent back to the browser together, and apparently there is either no time to display the notification, or the application close supersedes it).
With the background thread and the progress indicator, I the notification message is displayed (good), but then I get a session error is displayed (bad) when the application is closed and I do not get sent to the logout page (because the application actually IS being closed ? and closes the session at the same time ? which the browser detects as a session error instead of an application close ?).
Suggestions? I’ve already spent too long on this…