Class LitComponent
- All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier
,com.vaadin.flow.component.DetachNotifier
,com.vaadin.flow.component.HasElement
,com.vaadin.flow.component.HasStyle
,com.vaadin.flow.internal.Template
,Serializable
- Direct Known Subclasses:
BrowserMessage
,Clock
,FlowDiagram
,FormSubmit
,RedirectSAML
,SOChart
,Stepper
,Template
,TimerComponent
This is a simple base component to create a Vaadin component from a LitElement that supports easy execution of Javascript. Normally, execution of Javascript is possible only when the front-end part of the component is attached to the DOM tree and in a ready-state. Vaadin makes sure that the JS commands are executed only when the component is attached. However, there is no guarantee that the component is still in a ready state at that time because of the complexity of the logic in the component.
This class caches all the commands till the front-end is ready to receive commands.
The LitElement (client-side) implementation should invoke the server-side ready()
method from the
connectedCallback() { super.connectedCallback(); this.$server.ready(); } or from any other suitable place when the
element is fully ready to receive updates from the server side. If you are using TS instead of JS, please make sure
that you cast the "this" as "any" to comply with the strong typing of TS - (this as any).$server.ready();
Since this component is extended from Vaadin's LitTemplate
, it has all the features supported by
that class too.
- Author:
- Syam
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected com.vaadin.flow.component.page.PendingJavaScriptResult
executeJS
(String function, Serializable... parameters) Execute Javascript function with the parameter passed.protected void
onDetach
(com.vaadin.flow.component.DetachEvent detachEvent) Methods inherited from class com.vaadin.flow.component.littemplate.LitTemplate
getChildren
Methods inherited from class com.vaadin.flow.component.Component
addListener, findAncestor, fireEvent, from, get, getElement, getEventBus, getId, getListeners, getLocale, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onAttach, onEnabledStateChanged, scrollIntoView, set, setElement, setId, setVisible
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListener
Methods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListener
Methods inherited from interface com.vaadin.flow.component.HasElement
getElement
Methods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName
-
Constructor Details
-
LitComponent
public LitComponent()
-
-
Method Details
-
executeJS
protected com.vaadin.flow.component.page.PendingJavaScriptResult executeJS(String function, Serializable... parameters) Execute Javascript function with the parameter passed. Execution will be delayed till the front-end is ready.- Parameters:
function
- Javascript function to execute,parameters
- Parameters of the function.- Returns:
- Result details.
-
onDetach
protected void onDetach(com.vaadin.flow.component.DetachEvent detachEvent) - Overrides:
onDetach
in classcom.vaadin.flow.component.Component
-