Package io.jmix.ui.component.impl
Class JavaScriptComponentImpl
java.lang.Object
io.jmix.ui.component.impl.AbstractComponent<JmixJavaScriptComponent>
io.jmix.ui.component.impl.JavaScriptComponentImpl
- All Implemented Interfaces:
AttachNotifier,Component,Component.BelongToFrame,Component.HasCaption,Component.HasDescription,Component.HasIcon,Component.HasXmlDescriptor,Component.Wrapper,HasContextHelp,HasDebugId,HasHtmlCaption,HasHtmlDescription,HasHtmlSanitizer,HasRequiredIndicator,JavaScriptComponent
public class JavaScriptComponentImpl
extends AbstractComponent<JmixJavaScriptComponent>
implements JavaScriptComponent
-
Nested Class Summary
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.ContextHelpIconClickEventNested classes/interfaces inherited from interface io.jmix.ui.component.JavaScriptComponent
JavaScriptComponent.ClientDependency, JavaScriptComponent.DependencyType, JavaScriptComponent.JavaScriptCallbackEvent -
Field Summary
Fields inherited from class io.jmix.ui.component.impl.AbstractComponent
alignment, applicationContext, component, contextHelpIconClickHandler, contextHelpIconClickListener, descriptionAsHtml, element, frame, htmlSanitizerEnabled, icon, ICON_STYLE, id, parentFields inherited from interface io.jmix.ui.component.Component
AUTO_SIZE, AUTO_SIZE_PX, FULL_SIZEFields inherited from interface io.jmix.ui.component.JavaScriptComponent
NAME -
Constructor Summary
Constructors -
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.protected JmixJavaScriptComponentgetState()protected voidinitComponent(JmixJavaScriptComponent component) booleanReturns whether a required indicator should be shown.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.voidsetRequiredIndicatorVisible(boolean visible) Sets whether a required indicator should be shown.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 class io.jmix.ui.component.impl.AbstractComponent
addAttachListener, addDetachListener, addStyleName, assignDebugId, attached, detached, getAlignment, getCaption, getComponent, getComposition, getContextHelpIconClickHandler, getContextHelpText, getDebugId, getDescription, getEventHub, getFrame, getHeight, getHeightSizeUnit, getHtmlSanitizer, getIcon, getIconName, getIconResource, getId, getParent, getStyleName, getUiComponentProperties, getUiProperties, getWidth, getWidthSizeUnit, getXmlDescriptor, hasSubscriptions, hasValidationError, isAttached, isCaptionAsHtml, isContextHelpTextHtmlEnabled, isDescriptionAsHtml, isEnabled, isEnabledRecursive, isHtmlSanitizerEnabled, isResponsive, isVisible, isVisibleRecursive, onContextHelpIconClick, publish, removeStyleName, sanitize, setAlignment, setApplicationContext, setCaption, setCaptionAsHtml, setContextHelpIconClickHandler, setContextHelpText, setContextHelpTextHtmlEnabled, setDebugId, setDescription, setDescriptionAsHtml, setEnabled, setFrame, setHeight, setHtmlSanitizerEnabled, setIcon, setIconFromSet, setId, setParent, setResponsive, setStyleName, setValidationError, setVisible, setWidth, setXmlDescriptor, unsubscribe, unwrap, unwrapComposition, unwrapCompositionOrNull, unwrapOrNull, withUnwrapped, withUnwrappedCompositionMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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, setContextHelpTextHtmlEnabled
-
Constructor Details
-
JavaScriptComponentImpl
public JavaScriptComponentImpl()
-
-
Method Details
-
createComponent
-
initComponent
-
getDependencies
- Specified by:
getDependenciesin interfaceJavaScriptComponent- Returns:
- a list of dependencies
-
setDependencies
Description copied from interface:JavaScriptComponentSets 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://
- Specified by:
setDependenciesin interfaceJavaScriptComponent- Parameters:
dependencies- dependencies to set
- WebJar resource - starts with
-
addDependency
Description copied from interface:JavaScriptComponentAdds a dependency. Path path corresponds to one of the sources:- WebJar resource - starts with
webjar:// - VAADIN directory - starts with
vaadin://
- Specified by:
addDependencyin interfaceJavaScriptComponent- Parameters:
path- a dependency pathtype- a dependency type
- WebJar resource - starts with
-
addDependencies
Description copied from interface:JavaScriptComponentAdds dependency paths. Each path corresponds to one of the sources:- WebJar resource - starts with
webjar:// - VAADIN directory - starts with
vaadin://
- Specified by:
addDependenciesin interfaceJavaScriptComponent- Parameters:
dependencies- dependencies to add
- WebJar resource - starts with
-
getInitFunctionName
- Specified by:
getInitFunctionNamein interfaceJavaScriptComponent- Returns:
- an initialization function name that will be used to find an entry point for the JS component connector
-
setInitFunctionName
Description copied from interface:JavaScriptComponentSets 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.
- Specified by:
setInitFunctionNamein interfaceJavaScriptComponent- Parameters:
initFunctionName- an initialization function name
-
getState
- Specified by:
getStatein interfaceJavaScriptComponent- Returns:
- Returns a state object
-
setState
Description copied from interface:JavaScriptComponentSets 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.- Specified by:
setStatein interfaceJavaScriptComponent- Parameters:
state- a state object to set
-
addFunction
public void addFunction(String name, Consumer<JavaScriptComponent.JavaScriptCallbackEvent> function) Description copied from interface:JavaScriptComponentRegister 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.- Specified by:
addFunctionin interfaceJavaScriptComponent- Parameters:
name- the name that should be used for client-side functionfunction- theConsumerobject that will be invoked when the JavaScript function is called
-
callFunction
Description copied from interface:JavaScriptComponentInvoke 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.- Specified by:
callFunctionin interfaceJavaScriptComponent- Parameters:
name- the name of the functionarguments- function arguments
-
isRequiredIndicatorVisible
public boolean isRequiredIndicatorVisible()Description copied from interface:HasRequiredIndicatorReturns whether a required indicator should be shown.- Specified by:
isRequiredIndicatorVisiblein interfaceHasRequiredIndicator- Returns:
trueif a required indicator should be shown,falseotherwise
-
setRequiredIndicatorVisible
public void setRequiredIndicatorVisible(boolean visible) Description copied from interface:HasRequiredIndicatorSets whether a required indicator should be shown.- Specified by:
setRequiredIndicatorVisiblein interfaceHasRequiredIndicator- Parameters:
visible-trueif a required indicator should be shown,falseotherwise
-
repaint
public void repaint()Description copied from interface:JavaScriptComponentRepaint UI representation of the component.- Specified by:
repaintin interfaceJavaScriptComponent
-