Package io.jmix.ui.component
Interface JavaScriptComponent
- All Superinterfaces:
Component,Component.BelongToFrame,Component.HasCaption,Component.HasDescription,Component.HasIcon,HasContextHelp,HasRequiredIndicator
- All Known Implementing Classes:
JavaScriptComponentImpl
@StudioComponent(caption="JavaScriptComponent",
category="Containers",
xmlElement="jsComponent",
icon="io/jmix/ui/icon/container/jsComponent.svg",
canvasBehaviour=BOX,
documentationURL="https://docs.jmix.io/jmix/%VERSION%/ui/custom-components/js-component.html")
public interface JavaScriptComponent
extends Component, Component.HasCaption, Component.HasDescription, Component.HasIcon, Component.BelongToFrame, HasContextHelp, HasRequiredIndicator
A JavaScript wrapper.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classstatic enumThe type of dependency.static classAn event that is fired when a method is called by a client-side JavaScript function.Nested classes/interfaces inherited from interface io.jmix.ui.component.Component
Component.Alignment, Component.BelongToFrame, Component.Disposable, Component.Editable, Component.Focusable, Component.HasCaption, Component.HasDescription, Component.HasIcon, Component.HasXmlDescriptor, Component.WrapperNested classes/interfaces inherited from interface io.jmix.ui.component.HasContextHelp
HasContextHelp.ContextHelpIconClickEvent -
Field Summary
FieldsFields inherited from interface io.jmix.ui.component.Component
AUTO_SIZE, AUTO_SIZE_PX, FULL_SIZE -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDependencies(String... dependencies) Adds dependency paths.voidaddDependency(String path, JavaScriptComponent.DependencyType type) Adds a dependency.voidaddFunction(String name, Consumer<JavaScriptComponent.JavaScriptCallbackEvent> function) Register aConsumerthat can be called from the JavaScript using the provided name.voidcallFunction(String name, Object... arguments) Invoke a named function that the connector JavaScript has added to the JavaScript connector wrapper object.getState()voidrepaint()Repaint UI representation of the component.voidsetDependencies(List<JavaScriptComponent.ClientDependency> dependencies) Sets a list of dependencies.voidsetInitFunctionName(String initFunctionName) Sets an initialization function name that will be used to find an entry point for the JS component connector.voidSets a state object that can be used in the client-side JS connector and accessible from thedatafield of the component's state.Methods inherited from interface io.jmix.ui.component.Component
addStyleName, getAlignment, getHeight, getHeightSizeUnit, getId, getParent, getStyleName, getWidth, getWidthSizeUnit, isEnabled, isEnabledRecursive, isResponsive, isVisible, isVisibleRecursive, removeStyleName, setAlignment, setEnabled, setHeight, setHeightAuto, setHeightFull, setId, setParent, setResponsive, setSizeAuto, setSizeFull, setStyleName, setVisible, setWidth, setWidthAuto, setWidthFull, unwrap, unwrapComposition, unwrapCompositionOrNull, unwrapOrNull, withUnwrapped, withUnwrappedCompositionMethods inherited from interface io.jmix.ui.component.Component.BelongToFrame
getFrame, setFrameMethods inherited from interface io.jmix.ui.component.Component.HasCaption
getCaption, setCaptionMethods inherited from interface io.jmix.ui.component.Component.HasDescription
getDescription, setDescriptionMethods inherited from interface io.jmix.ui.component.Component.HasIcon
getIcon, setIcon, setIconFromSetMethods inherited from interface io.jmix.ui.component.HasContextHelp
getContextHelpIconClickHandler, getContextHelpText, isContextHelpTextHtmlEnabled, setContextHelpIconClickHandler, setContextHelpText, setContextHelpTextHtmlEnabledMethods inherited from interface io.jmix.ui.component.HasRequiredIndicator
isRequiredIndicatorVisible, setRequiredIndicatorVisible
-
Field Details
-
NAME
- See Also:
-
-
Method Details
-
getDependencies
List<JavaScriptComponent.ClientDependency> getDependencies()- Returns:
- a list of dependencies
-
setDependencies
Sets a list of dependencies. Each dependency represented with aJavaScriptComponent.ClientDependencyobject which path corresponds to one of the sources:- WebJar resource - starts with
webjar:// - VAADIN directory - starts with
vaadin://
- Parameters:
dependencies- dependencies to set
- WebJar resource - starts with
-
addDependency
Adds a dependency. Path path corresponds to one of the sources:- WebJar resource - starts with
webjar:// - VAADIN directory - starts with
vaadin://
- Parameters:
path- a dependency pathtype- a dependency type
- WebJar resource - starts with
-
addDependencies
Adds dependency paths. Each path corresponds to one of the sources:- WebJar resource - starts with
webjar:// - VAADIN directory - starts with
vaadin://
- Parameters:
dependencies- dependencies to add
- WebJar resource - starts with
-
getInitFunctionName
String getInitFunctionName()- Returns:
- an initialization function name that will be used to find an entry point for the JS component connector
-
setInitFunctionName
Sets an initialization function name that will be used to find an entry point for the JS component connector.CAUTION: the initialization function name must be unique within window.
- Parameters:
initFunctionName- an initialization function name
-
getState
Object getState()- Returns:
- Returns a state object
-
setState
Sets a state object that can be used in the client-side JS connector and accessible from thedatafield of the component's state.Here an example of accessing the state object:
connector.onStateChange = function () { var state = connector.getState(); let data = state.data; ... }The state object should be a POJO.
CAUTION:
Datefields serialized as strings withDateJsonSerializer.DATE_FORMATformat.- Parameters:
state- a state object to set
-
addFunction
Register aConsumerthat can be called from the JavaScript using the provided name. A JavaScript function with the provided name will be added to the connector wrapper object (initially available asthis). Calling that JavaScript function will cause the call method in the registeredConsumerto be invoked with the same arguments passed to theJavaScriptComponent.JavaScriptCallbackEvent.- Parameters:
name- the name that should be used for client-side functionfunction- theConsumerobject that will be invoked when the JavaScript function is called
-
callFunction
Invoke a named function that the connector JavaScript has added to the JavaScript connector wrapper object. The arguments can be any boxed primitive type, String,JsonValueor arrays of any other supported type. Complex types (e.g. List, Set, Map, Connector or any JavaBean type) must be explicitly serialized to aJsonValuebefore sending.- Parameters:
name- the name of the functionarguments- function arguments
-
repaint
void repaint()Repaint UI representation of the component.
-