Component 클래스의 주요 기능은 아래와 같습니다.
1. 오브젝트(인스턴스)를 생성/실행합니다.
2. showTo에 지정한 엘리먼트를 parent 엘리먼트로 하여 컴포넌트 실행 결과가 child Element로 설정됩니다.
3. component에 구조에 따라 DOM Tree가 결정됩니다.
4. defaultCcode를 각 컴포넌트의 ccode로 설정합니다.
- options.defaultCcode에 ccode를 지정하고 options.component에 ccode를 작성하지 않으면
defaultCcode의 값을 ccode를 작성하지 않은 모든 계층의 options.component에 설정합니다.
- component 계층 단위로 지정할 수 있으며 지정한 이하 계층의 모든 component에 설정됩니다.
5. 통합/융합된 컴포넌트 아키텍처와 메키니즘을 지원합니다.
6. Custom component에 MethodChain의 컴포넌트를 컴포넌트로 사용할 수 있습니다.
- namespace(package)를 등록합니다.
- 컴포넌트로 등록합니다.
- MethodChain 기본 형태로 클래스를 작성합니다.
- new my.group.myClass() options의 component에 MethodChain 컴포넌트를 ccode로 작성합니다.
mc.namespace('my.group');
mc.component.Code.add('mycode', 'new my.group.MyClass', 'mainMyClass');
my.group.MyClass = function(opts){
mc.widget.Widget.setOptions(this, opts);
if (this.showTo) {
this.mainMyClass(this.showTo);
}
};
my.group.MyClass.prototype = {
ccode: 'mycode',
id: 'mycode_id',
mainMyClass: function(showTo){
this.showTo = showTo || this.showTo;
mc.component.Component.isExec(this, 'mycode', this.showTo);
},
createMessage: function(){
}
}
mc.exec(function() {
new my.group.MyClass({
showTo: 'showArea',
component: [
{ccode: 'labeltext', label: {text: '스포츠', width: 50}},
{ccode: 'labeltext', label: {text: '책', width: 50}}
]
});
});
7. MethodChain에 Custom component를 컴포넌트로 사용할 수 있습니다.
- 4번 사례에서 아래의 코드를 제외한 나머지 코드는 같습니다.
- component에 ccode로 Custom Class를 작성합니다.
- component를 실행하면서 생성한 오브젝트의 메소드를 호출할 수도 있습니다.
ccode에 실행할 코드를 작성하면 됩니다.
mc.exec(function() {
new mc.panel.Panel({
showTo: 'resultArea',
width: 200,
component: [
{ccode: 'mycode'},
{ccode: 'labeltext', label: {text: '스포츠', width: 50}},
{ccode: "mc.component.Instance.get('mycode_id').createMessage()"}
]
});
});
8. component로 등록하지 않고 function() 형태를 지정할 수도 있습니다.
var myOptions = function(opts){};
var myNewFunction = function(opts){};
var sports = {};
sports.mySports = function(opts){};
new mc.panel.Panel({
showTo: 'showArea',
width: 500,
height: 150,
component: [
{ccode: myVarFunction},
{ccode: myOptions, id: 'my_options'},
{ccode: 'new myNewFunction(opts)'},
{ccode: 'new sports.mySports(opts)'}
]
});
| Options | Component |
|---|---|
|
|
|
| Method | Component |
|---|---|
isExec
(Object, String, HTMLElement) : Boolean
|
component.Component |
|
실행중인 컴포넌트가 마지막 클래스인 경우 mc.component.Component.exec()를 실행합니다.
|
|
isGroupExec
(Object, String, HTMLElement)
|
component.Component |
|
RadioGroup과 같이 클래스 내부에서 반복하여 Componet 인스턴스를 생성하는 경우에 사용합니다.
|
|
isOwn
(Object, String) : Boolean
|
component.Component |
|
this.ccode가 최종적으로 실행하는 클래스 여부를 체크합니다.
|
|
| Custom Event | Component |
|---|---|
| ready () | component.Component |
|
options 설정을 완료 했을 때 fire됩니다.
|
|