JSComponent
Overview
The JSComponent
class provides a set of methods for interacting with and managing components within a solution model. It offers functionality for setting and retrieving properties such as background, font type, borders, visibility, and positioning. Through various getter and setter methods, it allows for fine-tuned control over the component’s attributes, including handling design-time properties, setting Z-index values, and managing anchor configurations.
In addition to visual and layout properties, JSComponent
supports grouping components together by groupID
, enabling batch actions like enabling or disabling multiple elements at once. The class also supports retrieving and setting CSS position for components in NGClient, as well as managing event handlers and design-time properties. It provides utility methods for managing component attributes, including getting and setting attribute values, and clearing attributes when necessary.
Properties Summarized
Enables a component to stick to a specific side of form and/or to grow or shrink when a window is resized.
The background color of the component.
The type, color and style of border of the component.
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 font type of the component.
The foreground color of the component.
The Z index of this component.
A String representing a group ID for this component.
The height in pixels of the component.
The name of the component.
The name of the style class that should be applied to this component.
Flag that tells if the component is transparent or not.
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
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 UUID of this component.
Set a design-time property of an element.
Remove the attribute of an element.
Clear a design-time property of an element.
void
Set the attribute value of an element.
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 The anchor configuration for the component.
Sample
background
The background color of the component.
Type String The background color of the component.
Sample
borderType
The type, color and style of border of the component.
Type String The border type of the component as a string.
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 The CSS position of the component.
Sample
enabled
The enable state of the component, default true.
Type Boolean True if the component is enabled; false otherwise.
Sample
fontType
The font type of the component.
Type String The font type of the component.
Sample
foreground
The foreground color of the component.
Type String The foreground color of the component.
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 The Z-index of the component.
Sample
groupID
A String representing a group ID for this component. If several components have the same group ID then they belong to the same group of components. Using the group itself, all components can be disabled/enabled or made invisible/visible. The group id should be a javascript compatible identifier to allow access of the group in scripting.
Type String The group ID of the component.
Sample
height
The height in pixels of the component.
Type Number The width of the component in pixels.
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 The name of the component.
Sample
styleClass
The name of the style class that should be applied to this component.
When defining style classes for specific component types, their names must be prefixed according to the type of the component. For example in order to define a class names 'fancy' for fields, in the style definition the class must be named 'field.fancy'. If it would be intended for labels, then it would be named 'label.fancy'. When specifying the class name for a component, the prefix is dropped however. Thus the field or the label will have its styleClass property set to 'fancy' only.
Type String The CSS style class assigned to the component.
Sample
transparent
Flag that tells if the component is transparent or not.
The default value is "false", that is the components are not transparent.
Type Boolean True if the component is transparent; false otherwise.
Sample
visible
The visible property of the component, default true.
Type Boolean True if the component is visible; false otherwise.
Sample
width
The width in pixels of the component.
Type Number The width of the component in pixels.
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 The Y-coordinate position of the component.
Sample
Methods Detailed
getAttribute(name)
Get the value of an attribute of the element.
Parameters
String name the name of the attribute
Returns: Object The value of the specified attribute.
Sample
getAttributes()
Returns the attribute names of an element.
Returns: Array An array of attribute names for the component.
Sample
getComment()
Returns the comment of this component.
Returns: String the comment associated with this component.
Sample
getDesignTimeProperty(key)
Get a design-time property of an element.
Parameters
String key the name of the property
Returns: Object The value of the specified design-time property.
Sample
getDesignTimePropertyNames()
Get the design-time properties of an element.
Returns: Array An array of design-time property names for the component.
Sample
getFormName()
Returns the name of the form. (may be empty string as well)
Returns: String The name of the form containing the component.
Sample
getUUID()
Returns the UUID of this component.
Returns: UUID the UUID of this component.
Sample
putDesignTimeProperty(key, value)
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
Returns: Object The previous value of the specified design-time property, or null if none existed.
Sample
removeAttribute(name)
Remove the attribute of an element.
Parameters
String name the name of the attribute
Returns: String the deleted attribute value
Sample
removeDesignTimeProperty(key)
Clear a design-time property of an element.
Parameters
String key the name of the property
Returns: Object The removed value of the specified design-time property.
Sample
setAttribute(name, value)
Set the attribute value of an element.
Parameters
Returns: void
Sample
Last updated
Was this helpful?