Hi There,
I’m looking for a way to be able to re-use instances of views, to achieve the following: Suppose the user navigates from one view to another, then hits the ‘back’ button, the user might expect to return in the same view as before, so still having e.g. the same grid-rows selected, buttons selected etc.
I’d hoped that the Bakery example behaved in that way, but just found out it does not. This is the piece of code (from SpringVoewProvider) that we see creating a new instance of a view every time (even withing the same session), where we’d hope that the same view instance would be returned (for the same session):
protected View getViewFromApplicationContext(ViewInfo viewInfo) {
View view = null;
if (isAccessGranted(viewInfo)) {
final BeanDefinition beanDefinition = getBeanDefinitionRegistry()
.getBeanDefinition(viewInfo.getBeanName());
if (beanDefinition.getScope()
.equals(ViewScopeImpl.VAADIN_VIEW_SCOPE_NAME)) {
LOGGER.trace("View [{}]
is view scoped, activating scope",
viewInfo.getViewName());
final ViewCache viewCache = ViewScopeImpl
.getViewCacheRetrievalStrategy()
.getViewCache(getWebApplicationContext());
viewCache.creatingView(viewInfo.getViewName());
try {
view = getViewFromApplicationContextAndCheckAccess(
viewInfo);
} finally {
viewCache.viewCreated(viewInfo.getViewName(), view);
}
} else {
// view scope is not active for non-view-scope views as we don't
// hook into their lifecycle
view = getViewFromApplicationContextAndCheckAccess(viewInfo);
}
}
return view;
}