com.vaadin.ui.JavaScript Java Examples
The following examples show how to use
com.vaadin.ui.JavaScript.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BrowserCookie.java From viritin with Apache License 2.0 | 6 votes |
public static void detectCookieValue(String key, final Callback callback) { final String callbackid = "viritincookiecb"+UUID.randomUUID().toString().substring(0,8); JavaScript.getCurrent().addFunction(callbackid, new JavaScriptFunction() { private static final long serialVersionUID = -3426072590182105863L; @Override public void call(JsonArray arguments) { JavaScript.getCurrent().removeFunction(callbackid); if(arguments.length() == 0) { callback.onValueDetected(null); } else { callback.onValueDetected(arguments.getString(0)); } } }); JavaScript.getCurrent().execute(String.format( "var nameEQ = \"%2$s=\";var ca = document.cookie.split(';');for(var i=0;i < ca.length;i++) {var c = ca[i];while (c.charAt(0)==' ') c = c.substring(1,c.length); if (c.indexOf(nameEQ) == 0) {%1$s( c.substring(nameEQ.length,c.length)); return;};} %1$s();", callbackid,key )); }
Example #2
Source File: SwModuleTable.java From hawkbit with Eclipse Public License 1.0 | 5 votes |
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 }"))); }
Example #3
Source File: BrowserCookie.java From viritin with Apache License 2.0 | 5 votes |
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 )); }
Example #4
Source File: BrowserCookie.java From viritin with Apache License 2.0 | 5 votes |
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 )); }
Example #5
Source File: BrowserCookie.java From viritin with Apache License 2.0 | 4 votes |
public static void setCookie(String key, String value, String path) { JavaScript.getCurrent().execute(String.format( "document.cookie = \"%s=%s; path=%s\";", key, value, path )); }
Example #6
Source File: DesktopApplication.java From mycollab with GNU Affero General Public License v3.0 | 4 votes |
private void rememberTempAccount(String username, String password) { String storeVal = username + "$" + EnDecryptHelper.encryptText(password); String setCookieVal = String.format("var now = new Date(); now.setTime(now.getTime() + 1 * 1800 * 1000); " + "document.cookie = \"%s=%s; expires=\" + now.toUTCString() + \"; path=/\";", TEMP_ACCOUNT_COOKIE, storeVal); JavaScript.getCurrent().execute(setCookieVal); }
Example #7
Source File: JavaScriptUtil.java From usergrid with Apache License 2.0 | 4 votes |
private static void execute(String script) { JavaScript.getCurrent().execute(script); }
Example #8
Source File: JavaScriptUtil.java From usergrid with Apache License 2.0 | 4 votes |
private static void addCallback(String jsCallbackName, JavaScriptFunction jsCallback) { JavaScript.getCurrent().addFunction(jsCallbackName, jsCallback); }