return true;
}
private UI getBrowserDetailsUI(VaadinRequest request, VaadinSession session) {
VaadinService vaadinService = request.getService();
List<UIProvider> uiProviders = session.getUIProviders();
UIClassSelectionEvent classSelectionEvent = new UIClassSelectionEvent(
request);
UIProvider provider = null;
Class<? extends UI> uiClass = null;
for (UIProvider p : uiProviders) {
// Check for existing LegacyWindow
if (p instanceof LegacyApplicationUIProvider) {
LegacyApplicationUIProvider legacyProvider = (LegacyApplicationUIProvider) p;
UI existingUi = legacyProvider
.getExistingUI(classSelectionEvent);
if (existingUi != null) {
reinitUI(existingUi, request);
return existingUi;
}
}
uiClass = p.getUIClass(classSelectionEvent);
if (uiClass != null) {
provider = p;
break;
}
}
if (provider == null || uiClass == null) {
return null;
}
// Check for an existing UI based on window.name
// Special parameter sent by vaadinBootstrap.js
String windowName = request.getParameter("v-wn");
Map<String, Integer> retainOnRefreshUIs = session
.getPreserveOnRefreshUIs();
if (windowName != null && !retainOnRefreshUIs.isEmpty()) {
// Check for a known UI
Integer retainedUIId = retainOnRefreshUIs.get(windowName);
if (retainedUIId != null) {
UI retainedUI = session.getUIById(retainedUIId.intValue());
if (uiClass.isInstance(retainedUI)) {
reinitUI(retainedUI, request);
return retainedUI;
} else {
getLogger().info(
"Not using retained UI in " + windowName
+ " because retained UI was of type "
+ retainedUI.getClass() + " but " + uiClass
+ " is expected for the request.");
}
}
}
// No existing UI found - go on by creating and initializing one
Integer uiId = Integer.valueOf(session.getNextUIid());
// Explicit Class.cast to detect if the UIProvider does something
// unexpected
UICreateEvent event = new UICreateEvent(request, uiClass, uiId);
UI ui = uiClass.cast(provider.createInstance(event));
// Initialize some fields for a newly created UI
if (ui.getSession() != session) {
// Session already set for LegacyWindow
ui.setSession(session);
}
PushMode pushMode = provider.getPushMode(event);
if (pushMode == null) {
pushMode = session.getService().getDeploymentConfiguration()
.getPushMode();
}
ui.getPushConfiguration().setPushMode(pushMode);
Transport transport = provider.getPushTransport(event);
if (transport != null) {
ui.getPushConfiguration().setTransport(transport);
}
// Set thread local here so it is available in init
UI.setCurrent(ui);
ui.doInit(request, uiId.intValue());
session.addUI(ui);
// Remember if it should be remembered
if (vaadinService.preserveUIOnRefresh(provider, event)) {
// Remember this UI
if (windowName == null) {
getLogger().warning(
"There is no window.name available for UI " + uiClass
+ " that should be preserved.");