Interface JsInvokers
- All Superinterfaces:
Serializable
- All Known Subinterfaces:
AbstractNodeStateProvider.AttachExistingElementJs,AbstractRouteNotFoundError.CopilotJs,DndUtil.DndJs,Element.CallFunctionJs,Element.ElementJs,Element.ScrollIntoViewJs,ElementJsInitializerRegistration.InitializerJs,ExtendedClientDetails.ClientDetailsJs,Focusable.FocusJs,HasTextSelection.TextSelectionJs,History.HistoryJs,Hotswapper.RefreshUiJs,IFrame.ReloadJs,Page.NavigationJs,Page.PageJs,PublishedServerEventHandlerRpcHandler.PromiseJs,ScreenOrientation.ScreenOrientationJs,ShortcutRegistration.ShortcutJs,SignalInput.MirrorJs,UI.UiJs,UidlRequestHandler.MprPushStateJs,UIInternals.TitleJs,WakeLock.WakeLockJs,WebComponent.CustomEventJs,WebComponentBootstrapHandler.StylesheetJs,WebComponentUI.ThemeAttributesJs,WebPushJs,WebStorage.WebStorageJs
JsExpression, the
JavaScript they run when they are called. An implementation is obtained from
Element.executeJs(Class) or Page.executeJs(Class), and
calling a method of it schedules the declared JavaScript to run on the
client.
An interface that is passed to Element.executeJs(Class) or
Page.executeJs(Class) must itself be annotated with
JsDefinition, since annotations on interfaces are not inherited. The
annotation is what makes the interface findable during the build: its
JavaScript is collected into the generated bundle, so the client never has to
build a function from a string. That is what keeps a server-initiated call
compatible with a content security policy that does not allow
unsafe-eval. See JsDefinition for how a definition that
extends another interface is declared.
An interface whose methods only answer with snippets
extends JsSnippets instead. An interface can not extend both. Both
are Serializable, so an implementation can be kept in a field of a
component.
@JsDefinition
public interface ScrollJs extends JsInvokers {
@JsExpression("this.scrollTop = $0;")
void scrollTo(int top);
}
element.executeJs(ScrollJs.class).scrollTo(100);
- See Also: