diff options
Diffstat (limited to 'server/src/main/java/com/vaadin/ui/AbstractJavaScriptComponent.java')
-rw-r--r-- | server/src/main/java/com/vaadin/ui/AbstractJavaScriptComponent.java | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/server/src/main/java/com/vaadin/ui/AbstractJavaScriptComponent.java b/server/src/main/java/com/vaadin/ui/AbstractJavaScriptComponent.java index f643615b81..211d7aed27 100644 --- a/server/src/main/java/com/vaadin/ui/AbstractJavaScriptComponent.java +++ b/server/src/main/java/com/vaadin/ui/AbstractJavaScriptComponent.java @@ -40,9 +40,28 @@ import elemental.json.JsonValue; * <code>com_example_MyComponent</code> has not been defined. * <p> * JavaScript components have a very simple GWT widget ( - * {@link com.vaadin.client.ui.JavaScriptWidget} ) just consisting of a - * <code>div</code> element to which the JavaScript code should initialize its - * own user interface. + * {@link com.vaadin.client.ui.JavaScriptWidget} ) just consisting of a single + * element (a <code>div</code> by default) to which the JavaScript code should + * initialize its own user interface. The tag can be overridden by defining a + * string named <code>com_example_MyComponent.tag</code>. If no tag has been + * defined, a tag defined in a super class will be located in the same manner as + * with the init function. + * <p> + * For example, to create a component ({@code my.package.Span}) with the DOM + * {@code <span>some text</span>}, taking the {@code span} text from the state, + * the JavaScript would be: + * + * <pre> + * <code> +my_package_Span = function() { + this.onStateChange = function() { + this.getElement().innerText = this.getState().text; + } +} +my_package_Span.tag = "span"; +</code> + * </pre> + * * <p> * The initialization function will be called with <code>this</code> pointing to * a connector wrapper object providing integration to Vaadin. Please note that |