com.vaadin.ui.UI.close()方法的使用及代码示例

x33g5p2x  于2022-01-31 转载在 其他  
字(3.7k)|赞(0)|评价(0)|浏览(186)

本文整理了Java中com.vaadin.ui.UI.close()方法的一些代码示例,展示了UI.close()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。UI.close()方法的具体详情如下:
包路径:com.vaadin.ui.UI
类名称:UI
方法名:close

UI.close介绍

[英]Marks this UI to be #detach() from the session at the end of the current request, or the next request if there is no current request (if called from a background thread, for instance.)

The UI is detached after the response is sent, so in the current request it can still update the client side normally. However, after the response any new requests from the client side to this UI will cause an error, so usually the client should be asked, for instance, to reload the page (serving a fresh UI instance), to close the page, or to navigate somewhere else.

Note that this method is strictly for users to explicitly signal the framework that the UI should be detached. Overriding it is not a reliable way to catch UIs that are to be detached. Instead, UI.detach()should be overridden or a DetachListener used.
[中]在当前请求结束时将此UI标记为#detach(),如果没有当前请求,则将其标记为下一个请求(例如,如果从后台线程调用)
响应发送后,UI被分离,因此在当前请求中,它仍然可以正常更新客户端。但是,在响应之后,客户端对该UI的任何新请求都会导致错误,因此通常应该要求客户端重新加载页面(为新的UI实例提供服务)、关闭页面或导航到其他地方。
请注意,这种方法严格来说是为了让用户明确地向框架发出应该分离UI的信号。重写它并不是捕获要分离的UI的可靠方法。而是UI。应该重写detach()或使用DetachListener。

代码示例

代码示例来源:origin: com.vaadin/vaadin-server

/**
 * Adds an initialized UI to this session.
 *
 * @param ui
 *            the initialized UI to add.
 */
public void addUI(UI ui) {
  assert hasLock();
  if (ui.getUIId() == -1) {
    throw new IllegalArgumentException(
        "Can not add an UI that has not been initialized.");
  }
  if (ui.getSession() != this) {
    throw new IllegalArgumentException(
        "The UI belongs to a different session");
  }
  Integer uiId = Integer.valueOf(ui.getUIId());
  uIs.put(uiId, ui);
  String embedId = ui.getEmbedId();
  if (embedId != null) {
    Integer previousUiId = embedIdMap.put(embedId, uiId);
    if (previousUiId != null) {
      UI previousUi = uIs.get(previousUiId);
      assert previousUi != null && embedId.equals(previousUi
          .getEmbedId()) : "UI id map and embed id map not in sync";
      // Will fire cleanup events at the end of the request handling.
      previousUi.close();
    }
  }
}

代码示例来源:origin: com.vaadin/vaadin-server

/**
 * Closes those UIs in the given session for which {@link #isUIActive}
 * yields false.
 *
 * @since 7.0.0
 */
private void closeInactiveUIs(VaadinSession session) {
  final String sessionId = session.getSession().getId();
  for (final UI ui : session.getUIs()) {
    if (!isUIActive(ui) && !ui.isClosing()) {
      ui.accessSynchronously(() -> {
        getLogger().log(Level.FINE,
            "Closing inactive UI #{0} in session {1}",
            new Object[] { ui.getUIId(), sessionId });
        ui.close();
      });
    }
  }
}

代码示例来源:origin: de.mhus.lib/mhu-lib-vaadin

@Override
public void close() {
  super.close();
}

代码示例来源:origin: com.vaadin/vaadin-server

ui.close();

代码示例来源:origin: com.vaadin/hummingbird-server

@Override
  public void execute() {
    getLogger().log(Level.FINE,
        "Closing inactive UI #{0} in session {1}",
        new Object[] { ui.getUIId(), sessionId });
    ui.close();
  }
});

代码示例来源:origin: korpling/ANNIS

@Override
public void close()
{
 if (pluginManager != null)
 {
  pluginManager.shutdown();
 }
 super.close();
}

代码示例来源:origin: stackoverflow.com

UI popUp, mainUI;
popUp = UI.getCurrent();
JavaScript.eval("close()");
popUp.close(); 

VaadinSession session = getSession();
mainUI = session.getUIById(mainUIId);
UI.setCurrent(mainUI);

代码示例来源:origin: nz.co.senanque/madura-vaadin

public void logout(UI ui) {
  close();
  VaadinService.getCurrentRequest().getWrappedSession().invalidate();
  ui.close();
  String contextPath = VaadinService.getCurrentRequest().getContextPath();
  ui.getPage().setLocation(contextPath);
}

代码示例来源:origin: org.opennms.features.topology/org.opennms.features.topology.app

UI.getCurrent().close();

代码示例来源:origin: OpenNMS/opennms

UI.getCurrent().close();

代码示例来源:origin: de.mhus.lib/mhu-lib-vaadin

@Override
  public void menuSelected(MenuItem selectedItem) {
    try {
      getApi().getAccessControl().signOut();
    } catch (Throwable t) {
      log.d(t);
    }
    try {
      UI.getCurrent().close();
    } catch (Throwable t) {
      log.d(t);
    }
    UI.getCurrent().getPage().reload();
  }
});

相关文章