String embedId = getEmbedId(request);
UI retainedUI = session.getUIByEmbedId(embedId);
if (retainedUI != null) {
if (vaadinService.preserveUIOnRefresh(provider, new UICreateEvent(
request, uiClass))) {
if (uiClass.isInstance(retainedUI)) {
reinitUI(retainedUI, request);
return retainedUI;
} else {
getLogger().info(
"Not using the preserved UI " + embedId
+ " because it is of type "
+ retainedUI.getClass() + " but " + uiClass
+ " is expected for the request.");
}
}
/*
* Previous UI without preserve on refresh will be closed when the
* new UI gets added to the session.
*/
}
// 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