JSWebComponent
Last updated
Was this helpful?
Last updated
Was this helpful?
JSWebComponent
provides a wrapper for creating and managing web components in the Solution Model. It extends the JSComponent
model and allows developers to define custom behaviors, attributes, and design-time properties. Web components are essential for building dynamic, responsive forms in web-based Servoy applications. ## Functionality
JSWebComponent includes properties such as cssPosition
and anchors
for defining layout behaviors, making it adaptable to resizing and responsive designs. Visibility, dimensions, and coordinates can be controlled via properties like x
, y
, width
, height
, and visible
. The typeName
property identifies the type of web component, as defined in the specification file.
Methods such as getAttribute
, setJSONProperty
, and getHandler
provide tools for managing attributes, design-time properties, and event handlers. These methods enable dynamic configuration and integration of web components into forms. Utilities like getAttributes
and getUUID
facilitate introspection and metadata access.
JSWebComponent supports both design-time and runtime modifications, allowing components to be customized during development or adjusted dynamically at runtime.
For more details, refer to the section of this documentation.
Enables a component to stick to a specific side of form and/or to grow or shrink when a window is resized.
CSS position is a replacement for anchoring system making it more intuitive to place a component.
The enable state of the component, default true.
The Z index of this component.
The height in pixels of the component.
The name of the component.
The webcomponent type (name from the spec).
The visible property of the component, default true.
The width in pixels of the component.
The x coordinate of the component on the form.
The y coordinate of the component on the form.
Get the value of an attribute of the element.
Returns the attribute names of an element.
Returns the comment of this component.
Get a design-time property of an element.
Get the design-time properties of an element.
Returns the name of the form.
Returns the JSMethod handler with the given name.
Get the design-time value of the given property.
Get the list of property names this component supports.
Returns the UUID of this component.
Returns whatever the design-time value of the given property was set.
Set a design-time property of an element.
Remove the attribute of an element.
Clear a design-time property of an element.
void
Similar to resetJSONProperty but for handlers.
void
Reset the design-time value of the given property.
void
Set the attribute value of an element.
void
Set the JSMethod handler for the given handler name.
void
Set the design-time value for the given property.
Enables a component to stick to a specific side of form and/or to grow or shrink when a window is resized.
If opposite anchors are activated then the component with grow or shrink with the window. For example if Top and Bottom are activated, then the component will grow/shrink when the window is vertically resized. If Left and Right are activated then the component will grow/shrink when the window is horizontally resized.
If opposite anchors are not activated, then the component will keep a constant distance from the sides of the window which correspond to the activated anchors.
Sample
CSS position is a replacement for anchoring system making it more intuitive to place a component. CSS position should be set on form, an absolute position form can either work with anchoring or with css position. This is only working in NGClient.
Sample
The enable state of the component, default true.
Sample
The Z index of this component. If two components overlap, then the component with higher Z index is displayed above the component with lower Z index.
Sample
The height in pixels of the component.
Sample
The name of the component. Through this name it can also accessed in methods. Must be a valid javascript name. (no - in the name or start with number)
Sample
The webcomponent type (name from the spec).
Sample
The visible property of the component, default true.
Sample
The width in pixels of the component.
Sample
The x coordinate of the component on the form.
Sample
The y coordinate of the component on the form.
Sample
Get the value of an attribute of the element.
Parameters
Sample
Returns the attribute names of an element.
Sample
Returns the comment of this component.
Sample
Get a design-time property of an element.
Parameters
Sample
Get the design-time properties of an element.
Sample
Returns the name of the form. (may be empty string as well)
Sample
Returns the JSMethod handler with the given name.
Parameters
Sample
Get the design-time value of the given property. If the value was never set and the component has default value for the give property, that value will be returned. To check if the value was set, use isJSONPropertySet.
Parameters
Sample
Get the list of property names this component supports. It can return all properties specified in spec file or only the properties that are set in json.
Parameters
Sample
Returns the UUID of this component.
Sample
Returns whatever the design-time value of the given property was set.
Parameters
Sample
Set a design-time property of an element. Value should be primitive data (string, boolean or number). Complex values should be stringified before call.
Parameters
Sample
Remove the attribute of an element.
Parameters
Sample
Clear a design-time property of an element.
Parameters
Sample
Similar to resetJSONProperty but for handlers.
Parameters
Returns: void
Sample
Reset the design-time value of the given property. This makes it as if it was never set. It can be useful when working with form inheritance.
Parameters
Returns: void
Sample
Set the attribute value of an element.
Parameters
Returns: void
Sample
Set the JSMethod handler for the given handler name. The handlerName is checked for existence in the component spec file, if the component does not declare this handler, an error is thrown. If the handler is already set, it will be replaced with the new JSMethod.
Parameters
Returns: void
Sample
Set the design-time value for the given property. For primitive property types you can just set the value. For more complex property types you can set a JSON value similar to what would be generated in the .frm file if you would design what you need using editor/properties view. Some property types can be assigned values in the runtime accepted format (for example border, font typed properties have a string representation at runtime and here as well).
Parameters
Returns: void
Sample
Type The anchor configuration for the component.
Type The CSS position of the component.
Type True if the component is enabled; false otherwise.
Type The Z-index of the component.
Type The width of the component in pixels.
Type The name of the component.
Type the type name of the web component, as defined in the specification file.
Type True if the component is visible; false otherwise.
Type The width of the component in pixels.
Type
Type The Y-coordinate position of the component.
name the name of the attribute
Returns: The value of the specified attribute.
Returns: An array of attribute names for the component.
Returns: the comment associated with this component.
key the name of the property
Returns: The value of the specified design-time property.
Returns: An array of design-time property names for the component.
Returns: The name of the form containing the component.
handlerName the name of the handler to get
Returns: the JSMethod handler associated with the specified handler name.
propertyName the name of the property to get
Returns: the design-time value of the specified property, or the default value if not set.
includeAll whether to return all properties from specification file or only the ones that are set in json
Returns: an array of property names supported by the web component. Includes all properties or only set properties based on the includeAll parameter.
Returns: the UUID of this component.
propertyName the name of the property to check
Returns: true if the specified property is explicitly set, otherwise false.
key the name of the property
value the value to store
Returns: The previous value of the specified design-time property, or null if none existed.
name the name of the attribute
Returns: the deleted attribute value
key the name of the property
Returns: The removed value of the specified design-time property.
handlerName the name of the handler to reset
propertyName the name of the property to reset
name the name of the attribute
value the value of the attribute
handlerName the name of the handler to get
method the JSMethod to attach to the handler (can be also JSMethod that has arguments)
propertyName the name of the property to set
value the new value of the property