Caplin Trader 5.1.0

Interface: module:ct-component/Component

module:ct-component/Component

This interface must be implemented by a presentation-level class. A presentation-level class represents something that occupies physical space in the page container, such as the content of a panel or a dialog box. Component extends the module:ct-component/ComponentLifecycleEvents interface which defines the life cycle events that may be raised by the container in response to the user's interaction with it. The Component is automatically registered with its container so that it receives these life cycle event callbacks.

Each implementation of a Component represents a different Component type, for example a Grid or a Trade Panel.

Each subclass of Component must have an createFromSerializedState method which is responsible for constructing new instances of the Component.

The windowing environment, which provides the container within which the component exists, may only use a subset of the Component interface. A component therefore should be implemented so that it will work even if the (mandatory) methods module:ct-component/Component#getElement and module:ct-component/ComponentLifecycleEvents#onOpen are the only methods the windowing environment will invoke.

The windowing environment determines whether the event methods are called immediately after or immediately before the event they refer to.

Component instances that have been configured via XML or saved as part of a layout are instantiated by the ComponentFactory. As such a Component must be registered with the using the factory's module:ct-component/ComponentFactory#registerComponent method, passing in the name of the root XML tag that represents the component and a suitable static factory method can instantiate it.

Implements:

Methods

getContainer() → {module:ct-component/container/Container}

Returns a reference to the container that is hosting this component. If no container has been set then this will return undefined.

Deprecated:
  • Yes
Returns:

oContainer The container hosting this component.

Type
module:ct-component/container/Container

getElement() → {HtmlElement}

Invoked when the windowing environment needs to display this component. It returns the HTML element that must be added to the DOM to represent this component. getElement() is invoked before any of the other Component interface methods.

This method is compulsory, and must be implemented.

It should be designed execute quickly, as the windowing environment may freeze until it has returned.

Throws:

if this method is not implemented by the subclass.

Type
module:ct-core/Error
Returns:

The root HtmlElement used to display this component on a web page. Must not be null or undefined.

Type
HtmlElement

getPermissionKey() → {module:ct-services/security/PermissionKey}

Invoked so the container can determine whether the component is currently permissioned for use.

Returns:

getUniqueComponentId() → {String}

Gets a guaranteed ID for this component instance.

Returns:

A unique ID

Type
String

setContainer(oContainer)

Provides a reference to the container that will be hosting this component.

Parameters:
Name Type Description
oContainer module:ct-component/container/Container

The container hosting this component.

Deprecated:
  • Yes
See:

setFrame(oComponentFrame)

Provides a reference to the frame enclosure, that wraps this component so it can be displayed on the page.

Parameters:
Name Type Description
oComponentFrame module:ct-component/frame/ComponentFrame

The frame enclosure that wraps this component.