Caplin Trader 4.8.0

Namespace: caplin/component

caplin/component

Provides the module:caplin/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:caplin/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:

xyztrader.MyComponent = function() {
	// construct the component here - including storing any arguments that were passed in
};
caplin.implement(xyztrader.MyComponent, caplin.component.Component);

// ...
// implementation of the caplin.component.Component methods
// ...

// static factory method for creating xyztrader.MyComponents from the specified XML string
xyztrader.MyComponent.createFromSerializedState = function(sXml) {
	// process the XML to extract any relevent state information
	return new xyztrader.MyComponent();
};

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