JSWebComponent
Overview
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 RuntimeWebComponent section of this documentation.
Extends
Properties Summarized
Type | Name | Summary |
---|---|---|
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. |
Methods Summarized
Type | Name | Summary |
---|---|---|
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. |
Properties Detailed
anchors
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.
Type Number
Sample
cssPosition
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.
Type CSSPosition
Sample
enabled
The enable state of the component, default true.
Type Boolean
Sample
formIndex
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.
Type Number
Sample
height
The height in pixels of the component.
Type Number
Sample
name
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)
Type String
Sample
typeName
The webcomponent type (name from the spec).
Type String
Sample
visible
The visible property of the component, default true.
Type Boolean
Sample
width
The width in pixels of the component.
Type Number
Sample
x
The x coordinate of the component on the form.
Type Number
Sample
y
The y coordinate of the component on the form.
Type Number
Sample
Methods Detailed
getAttribute(name)
Get the value of an attribute of the element.
Parameters
String name the name of the attribute
Returns: Object
Sample
getAttributes()
Returns the attribute names of an element.
Returns: Array
Sample
getComment()
Returns the comment of this component.
Returns: String
Sample
getDesignTimeProperty(key)
Get a design-time property of an element.
Parameters
String key the name of the property
Returns: Object
Sample
getDesignTimePropertyNames()
Get the design-time properties of an element.
Returns: Array
Sample
getFormName()
Returns the name of the form. (may be empty string as well)
Returns: String The name of the form.
Sample
getHandler(handlerName)
Returns the JSMethod handler with the given name.
Parameters
String handlerName the name of the handler to get
Returns: JSMethod
Sample
getJSONProperty(propertyName)
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
String propertyName the name of the property to get
Returns: Object
Sample
getJSONPropertyNames(includeAll)
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
Boolean includeAll whether to return all properties from specification file or only the ones that are set in json
Returns: Array
Sample
getUUID()
Returns the UUID of this component.
Returns: UUID
Sample
isJSONPropertySet(propertyName)
Returns whatever the design-time value of the given property was set.
Parameters
String propertyName the name of the property to check
Returns: Boolean
Sample