Notifications with multiple windows

Hello,

I’ve made a small application with 2 windows (one for public and one for administration purposes) that connects to a database using JDBC. The database connection is made in separate class and the instantiation of this class is the first thing that happens in the Application class. This is because one window shows data from the database as soon as it opens so the connection has to be ready.

When the database is down or something else goes wrong involving the database connection, I would like to notify my users using a Notification. What would be the best way to implement this behavior and where should I implement this?

When the connection is being made and something goes wrong, the windows don’t exist yet and haven’t been added to the Application. Also, is there a way to detect which window is being viewed or is ‘active’? Any tips or help would be greatly appreciated.

Thanks,
Philippe

Sound like you would benefit from using the “thread local pattern”. That is a simple way of having reference to Application (and to main window from there). Take a look:

http://vaadin.com/wiki/-/wiki/Main/ThreadLocal%20Pattern

However, to this to work nicely I’d recommend to attach the main window first (temporary if you like). That way you have a place to show something to the user if you have to.