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

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

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

UI.getEmbedId介绍

[英]Gets a string the uniquely distinguishes this UI instance based on where it is embedded. The embed identifier is based on the window.name DOM attribute of the browser window where the UI is displayed and the id of the div element where the UI is embedded.
[中]

代码示例

代码示例来源: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

/**
 * Called by the framework to remove an UI instance from the session because
 * it has been closed.
 *
 * @param ui
 *            the UI to remove
 */
public void removeUI(UI ui) {
  assert hasLock() : "Session is locked";
  assert UI.getCurrent() != null : "Current UI cannot be null";
  assert ui != null : "Removed UI cannot be null";
  assert UI.getCurrent().getUIId() == ui.getUIId() : "UIs don't match";
  Integer id = Integer.valueOf(ui.getUIId());
  ui.setSession(null);
  uIs.remove(id);
  String embedId = ui.getEmbedId();
  if (embedId != null && id.equals(embedIdMap.get(embedId))) {
    embedIdMap.remove(embedId);
  }
}

代码示例来源:origin: info.magnolia.ui/magnolia-ui-framework

UiContextReferenceImpl(UI ui) {
  this.uiId = String.format("%s:%d", ui.getEmbedId(), ui.getUIId());
}

代码示例来源:origin: info.magnolia.ui/magnolia-ui-framework

public StubVaadinSession(EventBus eventBus) {
  this.eventBus = eventBus;
  final VaadinServlet vaadinServlet = mock(VaadinServlet.class);
  final ServletConfig servletConfig = mock(ServletConfig.class);
  this.context = mock(ServletContext.class);
  doReturn(context).when(servletConfig).getServletContext();
  doReturn(servletConfig).when(vaadinServlet).getServletConfig();
  doReturn(context).when(vaadinServlet).getServletContext();
  this.ui = mock(UI.class);
  doReturn("foo").when(ui).getEmbedId();
  this.vaadinService = mock(VaadinServletService.class);
  doReturn(vaadinServlet).when(vaadinService).getServlet();
  this.vaadinSession = new VaadinSession(vaadinService) {
    @Override
    public boolean hasLock() {
      return true;
    }
  };
  this.vaadinSession.setAttribute(UI.class, this.ui);
  this.sessionStore = new SessionStore(vaadinSession, eventBus);
  this.vaadinSession.setAttribute(SessionStore.class, sessionStore);
}

代码示例来源:origin: info.magnolia.ui/magnolia-ui-framework-compatibility

private void setUpUISession() {
  final VaadinServlet vaadinServlet = mock(VaadinServlet.class);
  UI ui = mock(UI.class);
  doReturn("foo").when(ui).getEmbedId();
  VaadinServletService vaadinService = mock(VaadinServletService.class);
  doReturn(vaadinServlet).when(vaadinService).getServlet();
  VaadinSession vaadinSession = new VaadinSession(vaadinService) {
    @Override
    public boolean hasLock() {
      return true;
    }
  };
  vaadinSession.setAttribute(UI.class, ui);
  SessionStore sessionStore = new SessionStore(vaadinSession, eventBus);
  vaadinSession.setAttribute(SessionStore.class, sessionStore);
  UI.setCurrent(ui);
  VaadinSession.setCurrent(vaadinSession);
  VaadinService.setCurrent(vaadinService);
  sessionStore.createBeanStore(UiContextReference.ofCurrentUi());
  sessionStore.getBeanStore(UiContextReference.ofCurrentUi()).put(Key.get(AdmincentralFlavour.class), AdmincentralFlavour.ofM5);
}

相关文章