A creator is used to create new instances of component views. It is plugged-in into the Abcs system using the registration API (ComponentProviderRegistry).
This type of creator by default does not raise any UI when a component's view is creating, it expects the view is created immediately with default properties. If you want to raise a UI to tweak component's view creation, use one of UI creators:
- PopupCreator
- Raises a light-weight popup UI for modifying the view's properties and behaviour.
In order to add a creator for a new component create an object with methods described by Creator. The object must implement Creator.createView method creating a view instance, Creator.getType to specify the type of the creator and Creator.getOptions to specify creator options.
- Version:
- 16.3.5
- Source:
- See:
Example
define([
'components.dt/js/api/ComponentFactory',
'components.dt/js/spi/creators/CreatorType'
], function (ComponentFactory, CreatorType) {
'use strict';
var MyCreator = function () {
};
MyCreator.prototype.getType = function () {
return CreatorType.PLAIN;
};
MyCreator.prototype.createView = function (activePage, container, createContext) {
var componentFactory = ComponentFactory.create(activePage);
var properties = {
text: createContext && createContext.text || 'Default Text'
};
var view = componentFactory.createView({
type: 'org.my.myComponent',
properties: properties,
displayName: 'My Component'
});
return view;
};
MyCreator.prototype.getOptions = function () {
return {
// the creator is expected to create only one type of view: org.my.myComponent
possibleGeneratedViewTypes: ['org.my.myComponent'],
// min width of the component will be 2 columns
minWidth: 2
};
};
return MyCreator;
});
Object Literals
Methods
createView(activePage, container, createContext) → {pages.dt/js/api/View}
stable API
Creates a specific View for the component.
MUST be implemented.
The main purpose of this method is to create a full working instance of a View representing the top of your component hieararchy. You do not call its constructor directly but rather call the ComponentFactory.createView factory method taking care of lots of things for you.
See Creator for an example on how to implement this method.
Parameters:
Name | Type | Description |
---|---|---|
activePage |
pages.dt/js/api/Page | the current page the view is created for. |
container |
pages.dt/js/api/View | undefined | parent container the view is about to be added into.
May be |
createContext |
Object | object with set of default properties used to create specific view instance with default properties or possibly even reconstruct an old view from a serialized context. |
- Version:
- 16.3.5
- Source:
- See:
Returns:
created View.
- Type
- pages.dt/js/api/View
getOptions() → {components.dt/js/spi/creators/Creator.CreatorOptions}
stable API
Get the options which will be used by designer infrastructure.
- Version:
- 16.3.5
- Source:
Returns:
getType() → {components.dt/js/spi/creators/CreatorType}
stable API
Specifies the type of the creator.
Every creator must specify its type (if it's a non-UI plain creator, a popup creator or another). Plain creators must return CreatorType.PLAIN type.
- Version:
- 16.3.5
- Source:
Returns:
creator type