Caplin Trader 5.1.0

Namespace: ct-component

ct-component

Provides the module:ct-component/Component interface that must be implemented by any classes that want to be loaded into a Panel or dialog.

All Components must have a suitable static factory method registered along with the name of the root XML node that represents the component with the module:ct-component/ComponentFactory#registerComponent method. Whenever an application needs to construct a component with a specified root XML node, the registered static factory method will be invoked. An example of this is included below:

class MyComponent extends Component {
 constructor() {
	    // construct the component here - including storing any arguments that
     // were passed in.
 }

 // static factory method for creating MyComponent from the XML string
 createFromSerializedState(xml) {
     // process the XML to extract any relevent state information
     return new MyComponent();
 }

 // ...
 // implementation of the Component methods
 // ...
}

// register createFromSerializedState static factory method with the
// ComponentFactory for XML node myComponent.
ComponentFactory.registerComponent("myComponent", MyComponent.createFromSerializedState);