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.Wrapper
Nested classes/interfaces inherited from interface io.jmix.ui.component.HasContextHelp
HasContextHelp.ContextHelpIconClickEvent
Nested 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, parent
Fields inherited from interface io.jmix.ui.component.Component
AUTO_SIZE, AUTO_SIZE_PX, FULL_SIZE
Fields inherited from interface io.jmix.ui.component.JavaScriptComponent
NAME
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addDependencies
(String... dependencies) Adds dependency paths.void
addDependency
(String path, JavaScriptComponent.DependencyType type) Adds a dependency.void
addFunction
(String name, Consumer<JavaScriptComponent.JavaScriptCallbackEvent> function) Register aConsumer
that can be called from the JavaScript using the provided name.void
callFunction
(String name, Object... arguments) Invoke a named function that the connector JavaScript has added to the JavaScript connector wrapper object.protected JmixJavaScriptComponent
getState()
protected void
initComponent
(JmixJavaScriptComponent component) boolean
Returns whether a required indicator should be shown.void
repaint()
Repaint UI representation of the component.void
setDependencies
(List<JavaScriptComponent.ClientDependency> dependencies) Sets a list of dependencies.void
setInitFunctionName
(String initFunctionName) Sets an initialization function name that will be used to find an entry point for the JS component connector.void
setRequiredIndicatorVisible
(boolean visible) Sets whether a required indicator should be shown.void
Sets a state object that can be used in the client-side JS connector and accessible from thedata
field 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, withUnwrappedComposition
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
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, withUnwrappedComposition
Methods inherited from interface io.jmix.ui.component.Component.BelongToFrame
getFrame, setFrame
Methods inherited from interface io.jmix.ui.component.Component.HasCaption
getCaption, setCaption
Methods inherited from interface io.jmix.ui.component.Component.HasDescription
getDescription, setDescription
Methods inherited from interface io.jmix.ui.component.Component.HasIcon
getIcon, setIcon, setIconFromSet
Methods 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:
getDependencies
in interfaceJavaScriptComponent
- Returns:
- a list of dependencies
-
setDependencies
Description copied from interface:JavaScriptComponent
Sets a list of dependencies. Each dependency represented with aJavaScriptComponent.ClientDependency
object which path corresponds to one of the sources:- WebJar resource - starts with
webjar://
- VAADIN directory - starts with
vaadin://
- Specified by:
setDependencies
in interfaceJavaScriptComponent
- Parameters:
dependencies
- dependencies to set
- WebJar resource - starts with
-
addDependency
Description copied from interface:JavaScriptComponent
Adds a dependency. Path path corresponds to one of the sources:- WebJar resource - starts with
webjar://
- VAADIN directory - starts with
vaadin://
- Specified by:
addDependency
in interfaceJavaScriptComponent
- Parameters:
path
- a dependency pathtype
- a dependency type
- WebJar resource - starts with
-
addDependencies
Description copied from interface:JavaScriptComponent
Adds dependency paths. Each path corresponds to one of the sources:- WebJar resource - starts with
webjar://
- VAADIN directory - starts with
vaadin://
- Specified by:
addDependencies
in interfaceJavaScriptComponent
- Parameters:
dependencies
- dependencies to add
- WebJar resource - starts with
-
getInitFunctionName
- Specified by:
getInitFunctionName
in 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:JavaScriptComponent
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.
- Specified by:
setInitFunctionName
in interfaceJavaScriptComponent
- Parameters:
initFunctionName
- an initialization function name
-
getState
- Specified by:
getState
in interfaceJavaScriptComponent
- Returns:
- Returns a state object
-
setState
Description copied from interface:JavaScriptComponent
Sets a state object that can be used in the client-side JS connector and accessible from thedata
field 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:
Date
fields serialized as strings withDateJsonSerializer.DATE_FORMAT
format.- Specified by:
setState
in interfaceJavaScriptComponent
- Parameters:
state
- a state object to set
-
addFunction
public void addFunction(String name, Consumer<JavaScriptComponent.JavaScriptCallbackEvent> function) Description copied from interface:JavaScriptComponent
Register aConsumer
that 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 registeredConsumer
to be invoked with the same arguments passed to theJavaScriptComponent.JavaScriptCallbackEvent
.- Specified by:
addFunction
in interfaceJavaScriptComponent
- Parameters:
name
- the name that should be used for client-side functionfunction
- theConsumer
object that will be invoked when the JavaScript function is called
-
callFunction
Description copied from interface:JavaScriptComponent
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,JsonValue
or arrays of any other supported type. Complex types (e.g. List, Set, Map, Connector or any JavaBean type) must be explicitly serialized to aJsonValue
before sending.- Specified by:
callFunction
in interfaceJavaScriptComponent
- Parameters:
name
- the name of the functionarguments
- function arguments
-
isRequiredIndicatorVisible
public boolean isRequiredIndicatorVisible()Description copied from interface:HasRequiredIndicator
Returns whether a required indicator should be shown.- Specified by:
isRequiredIndicatorVisible
in interfaceHasRequiredIndicator
- Returns:
true
if a required indicator should be shown,false
otherwise
-
setRequiredIndicatorVisible
public void setRequiredIndicatorVisible(boolean visible) Description copied from interface:HasRequiredIndicator
Sets whether a required indicator should be shown.- Specified by:
setRequiredIndicatorVisible
in interfaceHasRequiredIndicator
- Parameters:
visible
-true
if a required indicator should be shown,false
otherwise
-
repaint
public void repaint()Description copied from interface:JavaScriptComponent
Repaint UI representation of the component.- Specified by:
repaint
in interfaceJavaScriptComponent
-