In a previous project using Vaadin 6 and Navigator7, we found it helpful to have a Guice scope which matched a "browser tab". This was for things like message bars, toolbars and breadcrumbs and made good use of the dependency injection paradigm.
In Vaadin 7, the nearest scope to this would be UI - so I have added a UIScope to the sample app. It seems to work, but still needs proper testing, so it resides in a separate branch for now.
One of the problems with this is that when a new UI is created it will almost certainly require injection of UIScope components - but the UI itself has not yet been constructed so cannot be used as a scope reference.
To get round this I use a surrogate key (an instance of UIKey), and hold it in CurrentInstance, a ThreadLocal store provided by Vaadin 7.
No comments:
Post a Comment