Java Code Examples for com.vaadin.flow.dom.Element#executeJs()
The following examples show how to use
com.vaadin.flow.dom.Element#executeJs() .
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: ReturnChannelView.java From flow with Apache License 2.0 | 6 votes |
public ReturnChannelView() { Element button = new Element("button"); button.setAttribute("id", "button"); button.setText("Send message to channel"); ReturnChannelRegistration channel = button.getNode() .getFeature(ReturnChannelMap.class) .registerChannel(arguments -> button.setText( "Click registered: " + arguments.getString(0))); button.executeJs( "this.addEventListener('click', function() { $0('hello') })", channel); getElement().appendChild(button); }
Example 2
Source File: Focusable.java From flow with Apache License 2.0 | 5 votes |
/** * Calls the <code>focus</code> function at the client, making the component * keyboard focused. * * @see <a href= * "https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus">focus * at MDN</a> */ default void focus() { /* * Use setTimeout to call the focus function only after the element is * attached, and after the initial rendering cycle, so webcomponents can * be ready by the time when the function is called. */ Element element = getElement(); // Using $0 since "this" won't work inside the function element.executeJs("setTimeout(function(){$0.focus()},0)", element); }
Example 3
Source File: SourceContent.java From flow with Apache License 2.0 | 5 votes |
private void addSourceCodeBlock(String text, String className) { Element pre = new Element("pre"); Element code = new Element("code"); pre.appendChild(code); code.setAttribute("spellcheck", "false"); code.getClassList().add(className); code.setText(text); getElement().appendChild(pre); code.executeJs("Prism.highlightElement(this);"); }
Example 4
Source File: WebComponentUI.java From flow with Apache License 2.0 | 4 votes |
private void attachComponentToUI(Element child, String elementId) { getElement().getStateProvider().appendVirtualChild( getElement().getNode(), child, NodeProperties.INJECT_BY_ID, elementId); child.executeJs("$0.serverConnected()"); }