Caplin Trader 4.7.1

Interface: module:caplin/component/Component

module:caplin/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:caplin/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:caplin/component/Component#getElement and module:caplin/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:caplin/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.

Implementations:
Implements:

Methods

getContainer() → {module:caplin/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.
Implementations:
  • module:caplin/grid/GridView#getContainer
  • module:caplin/presenter/component/PresenterComponent#getContainer
Deprecated:
  • Yes
Returns:
oContainer The container hosting this component.
Type
module:caplin/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.

Implementations:
  • module:caplin/component/ErrorComponent#getElement
  • module:caplin/grid/GridView#getElement
  • module:caplin/presenter/component/PresenterComponent#getElement
Throws:
if this method is not implemented by the subclass.
Type
module:caplin/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:caplin/services/security/PermissionKey}

Invoked so the container can determine whether the component is currently permissioned for use.
Implementations:
  • module:caplin/grid/GridView#getPermissionKey
  • module:caplin/presenter/component/PresenterComponent#getPermissionKey
Returns:

getUniqueComponentId() → {String}

Gets a guaranteed ID for this component instance.
Implementations:
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:caplin/component/container/Container The container hosting this component.
Implementations:
  • module:caplin/grid/GridView#setContainer
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:caplin/component/frame/ComponentFrame The frame enclosure that wraps this component.
Implementations:
  • module:caplin/presenter/component/PresenterComponent#setFrame