public class JavaScriptComponentImpl extends AbstractComponent<JmixJavaScriptComponent> implements JavaScriptComponent
JavaScriptComponent.ClientDependency, JavaScriptComponent.DependencyType, JavaScriptComponent.JavaScriptCallbackEventComponent.Alignment, Component.BelongToFrame, Component.Disposable, Component.Editable, Component.Focusable, Component.HasCaption, Component.HasDescription, Component.HasIcon, Component.HasXmlDescriptor, Component.WrapperHasContextHelp.ContextHelpIconClickEventalignment, applicationContext, component, contextHelpIconClickHandler, contextHelpIconClickListener, descriptionAsHtml, element, frame, htmlSanitizerEnabled, icon, ICON_STYLE, id, parentNAMEAUTO_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, withUnwrappedCompositionclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetCaption, setCaptiongetDescription, setDescriptiongetIcon, setIcon, setIconFromSetgetFrame, setFrameaddStyleName, 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, withUnwrappedCompositiongetContextHelpIconClickHandler, getContextHelpText, isContextHelpTextHtmlEnabled, setContextHelpIconClickHandler, setContextHelpText, setContextHelpTextHtmlEnabledprotected JmixJavaScriptComponent createComponent()
protected void initComponent(JmixJavaScriptComponent component)
public java.util.List<JavaScriptComponent.ClientDependency> getDependencies()
getDependencies in interface JavaScriptComponentpublic void setDependencies(java.util.List<JavaScriptComponent.ClientDependency> dependencies)
JavaScriptComponentJavaScriptComponent.ClientDependency object which path corresponds to one of the sources:
webjar://vaadin://setDependencies in interface JavaScriptComponentdependencies - dependencies to setpublic void addDependency(java.lang.String path,
JavaScriptComponent.DependencyType type)
JavaScriptComponentwebjar://vaadin://addDependency in interface JavaScriptComponentpath - a dependency pathtype - a dependency typepublic void addDependencies(java.lang.String... dependencies)
JavaScriptComponentwebjar://vaadin://addDependencies in interface JavaScriptComponentdependencies - dependencies to addpublic java.lang.String getInitFunctionName()
getInitFunctionName in interface JavaScriptComponentpublic void setInitFunctionName(java.lang.String initFunctionName)
JavaScriptComponentCAUTION: the initialization function name must be unique within window.
setInitFunctionName in interface JavaScriptComponentinitFunctionName - an initialization function namepublic java.lang.Object getState()
getState in interface JavaScriptComponentpublic void setState(java.lang.Object state)
JavaScriptComponentdata 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 JavaScriptComponentstate - a state object to setpublic void addFunction(java.lang.String name,
java.util.function.Consumer<JavaScriptComponent.JavaScriptCallbackEvent> function)
JavaScriptComponentConsumer 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 JavaScriptComponentname - 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)
JavaScriptComponentJsonValue 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 JavaScriptComponentname - the name of the functionarguments - function argumentspublic boolean isRequiredIndicatorVisible()
HasRequiredIndicatorisRequiredIndicatorVisible in interface HasRequiredIndicatortrue if a required indicator should be shown, false otherwisepublic void setRequiredIndicatorVisible(boolean visible)
HasRequiredIndicatorsetRequiredIndicatorVisible in interface HasRequiredIndicatorvisible - true if a required indicator should be shown, false otherwisepublic void repaint()
JavaScriptComponentrepaint in interface JavaScriptComponent