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

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

本文整理了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

  1. /**
  2. * Executes the given JavaScript code in the browser.
  3. *
  4. * @param script
  5. * The JavaScript code to run.
  6. */
  7. public static void eval(String script) {
  8. getCurrent().execute(script);
  9. }

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

  1. /**
  2. * Executes JavaScript in this window.
  3. *
  4. * <p>
  5. * This method allows one to inject javascript from the server to client. A
  6. * client implementation is not required to implement this functionality,
  7. * but currently all web-based clients do implement this.
  8. * </p>
  9. *
  10. * <p>
  11. * Executing javascript this way often leads to cross-browser compatibility
  12. * issues and regressions that are hard to resolve. Use of this method
  13. * should be avoided and instead it is recommended to create new widgets
  14. * with GWT. For more info on creating own, reusable client-side widgets in
  15. * Java, read the corresponding chapter in Book of Vaadin.
  16. * </p>
  17. *
  18. * @param script
  19. * JavaScript snippet that will be executed.
  20. *
  21. * @deprecated As of 7.0, use JavaScript.getCurrent().execute(String)
  22. * instead
  23. */
  24. @Deprecated
  25. public void executeJavaScript(String script) {
  26. getPage().getJavaScript().execute(script);
  27. }

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

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

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

  1. public void buttonClick(Button.ClickEvent event) {
  2. // Stop the server in a separate thread.
  3. final Thread thread = new Thread(new Runnable() {
  4. public void run() {
  5. server.stop();
  6. }
  7. });
  8. // avoid that catalina's WebappClassLoader.clearReferencesThreads warns about the thread because it is
  9. // part of the web application being stopped.
  10. thread.setContextClassLoader(null);
  11. thread.start();
  12. // Close the browser tab
  13. JavaScript.getCurrent().execute("close();");
  14. }
  15. });

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

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

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

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

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

  1. @Override
  2. public void doRevert() {
  3. super.doRevert();
  4. JavaScript js = Page.getCurrent().getJavaScript();
  5. js.execute("window.close();");
  6. }

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

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

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

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

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

  1. /**
  2. * Dynamic styles for window.
  3. *
  4. * @param top
  5. * int value
  6. * @param marginLeft
  7. * int value
  8. */
  9. protected void getPreviewButtonColor(final String color) {
  10. Page.getCurrent().getJavaScript().execute(HawkbitCommonUtil.getPreviewButtonColorScript(color));
  11. }

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

  1. /**
  2. * Get target style - Dynamically as per the color picked, cannot be done
  3. * from the static css.
  4. *
  5. * @param colorPickedPreview
  6. */
  7. private static void getTargetDynamicStyles(final String colorPickedPreview) {
  8. Page.getCurrent().getJavaScript()
  9. .execute(HawkbitCommonUtil.changeToNewSelectedPreviewColor(colorPickedPreview));
  10. }

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

  1. /**
  2. * Get target style - Dynamically as per the color picked, cannot be done
  3. * from the static css.
  4. *
  5. * @param colorPickedPreview
  6. */
  7. private static void getTargetDynamicStyles(final String colorPickedPreview) {
  8. Page.getCurrent().getJavaScript()
  9. .execute(HawkbitCommonUtil.changeToNewSelectedPreviewColor(colorPickedPreview));
  10. }

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

  1. /**
  2. * Dynamic styles for window.
  3. *
  4. * @param top
  5. * int value
  6. * @param marginLeft
  7. * int value
  8. */
  9. protected void getPreviewButtonColor(final String color) {
  10. Page.getCurrent().getJavaScript().execute(HawkbitCommonUtil.getPreviewButtonColorScript(color));
  11. }

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

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

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

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

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

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

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

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

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

  1. private void callElectronUiApi(String[] args) {
  2. JsonArray paramsArray = Json.createArray();
  3. int i = 0;
  4. for (String arg : args) {
  5. paramsArray.set(i, Json.create(arg));
  6. i++;
  7. }
  8. getPage().getJavaScript().execute("callElectronUiApi(" + paramsArray.toJson() + ")");
  9. }

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

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

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

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

相关文章