Engine

Engine is responsible for the injection of component attributes. The injection requires component constructor to provide the corresponding getter and setter method.

  1. Add the corresponding attribute node in the component structure XML after you registered Page and Row component. Following is the code sample:
    <?xml version="1.0" encoding="UTF-8"?>
    <PageFormatter>
      <Page id="page1">
        <Row draggable="1" id="row_b1223959791733" title="html_service"/>
      </Page>
    </PageFormatter>
  2. Define the constructor of BTTRow and add corresponding getter and setter methods of attributes that need to be injected by IOC container.
    function BTTRow(){}
    BTTRow.prototype= {
    	title: null,
    	draggable: null,
    	getTitle: function(){
    		return this.title;
    	},
    	setTitle: function(title){
    		this.title = title;
    	},
    	getDraggable:function(){
    		return this.draggable;
    	},
    	setDraggable:function(draggable){
    		this.draggable=draggable
    	}
    };
    BTTUtil.extend(BTTRow, BTTComponentBase); //let BTTRow inherit BTTComponentBase

In fact, besides injection of attributes, which are provided with getter and setter methods, the engine also do some other injections. For example, if you do not specify the id of one component, the engine will generate a unique number and assign it to the attribute ID of this component instance.

The infrastructure of IOC engine is shown as follows.

the infrastructure of IOC engine