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

x33g5p2x  于2022-01-22 转载在 JavaScript  
字(7.1k)|赞(0)|评价(0)|浏览(95)

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

JavaScript.execute介绍

[英]Executes the given JavaScript code in the browser.
[中]在浏览器中执行给定的JavaScript代码。

代码示例

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

/**
 * Executes the given JavaScript code in the browser.
 *
 * @param script
 *            The JavaScript code to run.
 */
public static void eval(String script) {
  getCurrent().execute(script);
}

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

/**
 * Executes JavaScript in this window.
 *
 * <p>
 * This method allows one to inject javascript from the server to client. A
 * client implementation is not required to implement this functionality,
 * but currently all web-based clients do implement this.
 * </p>
 *
 * <p>
 * Executing javascript this way often leads to cross-browser compatibility
 * issues and regressions that are hard to resolve. Use of this method
 * should be avoided and instead it is recommended to create new widgets
 * with GWT. For more info on creating own, reusable client-side widgets in
 * Java, read the corresponding chapter in Book of Vaadin.
 * </p>
 *
 * @param script
 *            JavaScript snippet that will be executed.
 *
 * @deprecated As of 7.0, use JavaScript.getCurrent().execute(String)
 *             instead
 */
@Deprecated
public void executeJavaScript(String script) {
  getPage().getJavaScript().execute(script);
}

代码示例来源:origin: viritin/viritin

public static void setCookie(String key, String value, String path) {
  JavaScript.getCurrent().execute(String.format(
      "document.cookie = \"%s=%s; path=%s\";", key, value, path
  ));
}

代码示例来源:origin: com.bsb.common.vaadin/com.bsb.common.vaadin7.embed

public void buttonClick(Button.ClickEvent event) {
    // Stop the server in a separate thread.
    final Thread thread = new Thread(new Runnable() {
      public void run() {
        server.stop();
      }
    });
    // avoid that catalina's WebappClassLoader.clearReferencesThreads warns about the thread because it is
    // part of the web application being stopped.
    thread.setContextClassLoader(null);
    thread.start();
    // Close the browser tab
    JavaScript.getCurrent().execute("close();");
  }
});

代码示例来源:origin: viritin/viritin

public static void setCookie(String key, String value, String path, LocalDateTime expirationTime) {
  String expires = toCookieGMTDate(expirationTime);
  JavaScript.getCurrent().execute(String.format(
      "document.cookie = \"%s=%s; path=%s\"; Expires=%s\";", key, value, path, expires
  ));
}

代码示例来源:origin: viritin/viritin

public static void setCookie(String key, String value, LocalDateTime expirationTime) {
  String expires = toCookieGMTDate(expirationTime);
  JavaScript.getCurrent().execute(String.format(
    "document.cookie = \"%s=%s; expires=%s\";", key, value, expires
  ));
}

代码示例来源:origin: com.haulmont.cuba/cuba-web

@Override
public void doRevert() {
  super.doRevert();
  JavaScript js = Page.getCurrent().getJavaScript();
  js.execute("window.close();");
}

代码示例来源:origin: org.eclipse.hawkbit/hawkbit-ui

private static void getDynamicStyles(final String colorPickedPreview) {
  Page.getCurrent().getJavaScript()
      .execute(HawkbitCommonUtil.changeToNewSelectedPreviewColor(colorPickedPreview));
}

代码示例来源:origin: eclipse/hawkbit

private static void getDynamicStyles(final String colorPickedPreview) {
  Page.getCurrent().getJavaScript()
      .execute(HawkbitCommonUtil.changeToNewSelectedPreviewColor(colorPickedPreview));
}

代码示例来源:origin: org.eclipse.hawkbit/hawkbit-ui

/**
 * Dynamic styles for window.
 *
 * @param top
 *            int value
 * @param marginLeft
 *            int value
 */
protected void getPreviewButtonColor(final String color) {
  Page.getCurrent().getJavaScript().execute(HawkbitCommonUtil.getPreviewButtonColorScript(color));
}

代码示例来源:origin: org.eclipse.hawkbit/hawkbit-ui

/**
 * Get target style - Dynamically as per the color picked, cannot be done
 * from the static css.
 *
 * @param colorPickedPreview
 */
private static void getTargetDynamicStyles(final String colorPickedPreview) {
  Page.getCurrent().getJavaScript()
      .execute(HawkbitCommonUtil.changeToNewSelectedPreviewColor(colorPickedPreview));
}

代码示例来源:origin: eclipse/hawkbit

/**
 * Get target style - Dynamically as per the color picked, cannot be done
 * from the static css.
 *
 * @param colorPickedPreview
 */
private static void getTargetDynamicStyles(final String colorPickedPreview) {
  Page.getCurrent().getJavaScript()
      .execute(HawkbitCommonUtil.changeToNewSelectedPreviewColor(colorPickedPreview));
}

代码示例来源:origin: eclipse/hawkbit

/**
 * Dynamic styles for window.
 *
 * @param top
 *            int value
 * @param marginLeft
 *            int value
 */
protected void getPreviewButtonColor(final String color) {
  Page.getCurrent().getJavaScript().execute(HawkbitCommonUtil.getPreviewButtonColorScript(color));
}

代码示例来源:origin: com.haulmont.cuba/cuba-web

@Override
public void actionPerform(Component component) {
  super.actionPerform(component);
  JavaScript js = Page.getCurrent().getJavaScript();
  js.execute("window.close();");
}

代码示例来源:origin: org.eclipse.hawkbit/hawkbit-ui

private void styleTableOnDistSelection() {
  Page.getCurrent().getJavaScript().execute(HawkbitCommonUtil.getScriptSMHighlightReset());
  setCellStyleGenerator(new Table.CellStyleGenerator() {
    private static final long serialVersionUID = 1L;
    @Override
    public String getStyle(final Table source, final Object itemId, final Object propertyId) {
      return createTableStyle(itemId, propertyId);
    }
  });
}

代码示例来源:origin: eclipse/hawkbit

private void styleTableOnDistSelection() {
  Page.getCurrent().getJavaScript().execute(HawkbitCommonUtil.getScriptSMHighlightReset());
  setCellStyleGenerator(new Table.CellStyleGenerator() {
    private static final long serialVersionUID = 1L;
    @Override
    public String getStyle(final Table source, final Object itemId, final Object propertyId) {
      return createTableStyle(itemId, propertyId);
    }
  });
}

代码示例来源:origin: org.eclipse.hawkbit/hawkbit-ui

private static void addTypeStyle(final Long tagId, final String color) {
  final JavaScript javaScript = UI.getCurrent().getPage().getJavaScript();
  UI.getCurrent()
      .access(() -> javaScript.execute(
          HawkbitCommonUtil.getScriptSMHighlightWithColor(".v-table-row-distribution-upload-type-" + tagId
              + "{background-color:" + color + " !important;background-image:none !important }")));
}

代码示例来源:origin: jreznot/electron-java-app

private void callElectronUiApi(String[] args) {
  JsonArray paramsArray = Json.createArray();
  int i = 0;
  for (String arg : args) {
    paramsArray.set(i, Json.create(arg));
    i++;
  }
  getPage().getJavaScript().execute("callElectronUiApi(" + paramsArray.toJson() + ")");
}

代码示例来源:origin: eclipse/hawkbit

private static void addTypeStyle(final Long tagId, final String color) {
  final JavaScript javaScript = UI.getCurrent().getPage().getJavaScript();
  UI.getCurrent()
      .access(() -> javaScript.execute(
          HawkbitCommonUtil.getScriptSMHighlightWithColor(".v-table-row-distribution-upload-type-" + tagId
              + "{background-color:" + color + " !important;background-image:none !important }")));
}

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

protected void doAdd() {
    List<Pair<String,Object>> options = getAddOptions();
    if (options == null || options.size() <= 0) return;
//        if (options.size() == 1) {
//            doAdd(options.get(0).getValue());
//        } else {
      
      menuAdd.removeAllItems();
      for (Pair<String, Object> item : options) {
        Pair<String, Object[]> out = new Pair<String, Object[]>(item.getKey(), new Object[] {"add", item.getValue()} );
        menuAdd.addItem(out);
      }
      String myCode = "$('#" + menuAdd.getId() + "').find('input')[0].click();";
      Page.getCurrent().getJavaScript().execute(myCode);
//        }
  }

相关文章