public class JavaScriptComponentImpl extends AbstractComponent<JmixJavaScriptComponent> implements JavaScriptComponent
JavaScriptComponent.ClientDependency, JavaScriptComponent.DependencyType, JavaScriptComponent.JavaScriptCallbackEvent
Component.Alignment, Component.BelongToFrame, Component.Disposable, Component.Editable, Component.Focusable, Component.HasCaption, Component.HasDescription, Component.HasIcon, Component.HasXmlDescriptor, Component.Wrapper
HasContextHelp.ContextHelpIconClickEvent
alignment, applicationContext, component, contextHelpIconClickHandler, contextHelpIconClickListener, descriptionAsHtml, element, frame, htmlSanitizerEnabled, icon, ICON_STYLE, id, parent
NAME
AUTO_SIZE, AUTO_SIZE_PX, FULL_SIZE
Constructor and Description |
---|
JavaScriptComponentImpl() |
Modifier and Type | Method and Description |
---|---|
void |
addDependencies(java.lang.String... dependencies)
Adds dependency paths.
|
void |
addDependency(java.lang.String path,
JavaScriptComponent.DependencyType type)
Adds a dependency.
|
void |
addFunction(java.lang.String name,
java.util.function.Consumer<JavaScriptComponent.JavaScriptCallbackEvent> function)
Register a
Consumer that can be called from the
JavaScript using the provided name. |
void |
callFunction(java.lang.String name,
java.lang.Object... arguments)
Invoke a named function that the connector JavaScript has added to the
JavaScript connector wrapper object.
|
protected JmixJavaScriptComponent |
createComponent() |
java.util.List<JavaScriptComponent.ClientDependency> |
getDependencies() |
java.lang.String |
getInitFunctionName() |
java.lang.Object |
getState() |
protected void |
initComponent(JmixJavaScriptComponent component) |
boolean |
isRequiredIndicatorVisible()
Returns whether a required indicator should be shown.
|
void |
repaint()
Repaint UI representation of the component.
|
void |
setDependencies(java.util.List<JavaScriptComponent.ClientDependency> dependencies)
Sets a list of dependencies.
|
void |
setInitFunctionName(java.lang.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 |
setState(java.lang.Object state)
Sets a state object that can be used in the client-side JS connector
and accessible from the
data field of the component's state. |
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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getCaption, setCaption
getDescription, setDescription
getIcon, setIcon, setIconFromSet
getFrame, setFrame
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
getContextHelpIconClickHandler, getContextHelpText, isContextHelpTextHtmlEnabled, setContextHelpIconClickHandler, setContextHelpText, setContextHelpTextHtmlEnabled
protected JmixJavaScriptComponent createComponent()
protected void initComponent(JmixJavaScriptComponent component)
public java.util.List<JavaScriptComponent.ClientDependency> getDependencies()
getDependencies
in interface JavaScriptComponent
public void setDependencies(java.util.List<JavaScriptComponent.ClientDependency> dependencies)
JavaScriptComponent
JavaScriptComponent.ClientDependency
object which path corresponds to one of the sources:
webjar://
vaadin://
setDependencies
in interface JavaScriptComponent
dependencies
- dependencies to setpublic void addDependency(java.lang.String path, JavaScriptComponent.DependencyType type)
JavaScriptComponent
webjar://
vaadin://
addDependency
in interface JavaScriptComponent
path
- a dependency pathtype
- a dependency typepublic void addDependencies(java.lang.String... dependencies)
JavaScriptComponent
webjar://
vaadin://
addDependencies
in interface JavaScriptComponent
dependencies
- dependencies to addpublic java.lang.String getInitFunctionName()
getInitFunctionName
in interface JavaScriptComponent
public void setInitFunctionName(java.lang.String initFunctionName)
JavaScriptComponent
CAUTION: the initialization function name must be unique within window.
setInitFunctionName
in interface JavaScriptComponent
initFunctionName
- an initialization function namepublic java.lang.Object getState()
getState
in interface JavaScriptComponent
public void setState(java.lang.Object state)
JavaScriptComponent
data
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
with DateJsonSerializer.DATE_FORMAT
format.
setState
in interface JavaScriptComponent
state
- a state object to setpublic void addFunction(java.lang.String name, java.util.function.Consumer<JavaScriptComponent.JavaScriptCallbackEvent> function)
JavaScriptComponent
Consumer
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 as this
). Calling that JavaScript function will
cause the call method in the registered Consumer
to be
invoked with the same arguments passed to the JavaScriptComponent.JavaScriptCallbackEvent
.addFunction
in interface JavaScriptComponent
name
- the name that should be used for client-side functionfunction
- the Consumer
object that will be invoked
when the JavaScript function is calledpublic void callFunction(java.lang.String name, java.lang.Object... arguments)
JavaScriptComponent
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 a JsonValue
before sending.callFunction
in interface JavaScriptComponent
name
- the name of the functionarguments
- function argumentspublic boolean isRequiredIndicatorVisible()
HasRequiredIndicator
isRequiredIndicatorVisible
in interface HasRequiredIndicator
true
if a required indicator should be shown, false
otherwisepublic void setRequiredIndicatorVisible(boolean visible)
HasRequiredIndicator
setRequiredIndicatorVisible
in interface HasRequiredIndicator
visible
- true
if a required indicator should be shown, false
otherwisepublic void repaint()
JavaScriptComponent
repaint
in interface JavaScriptComponent