<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init();">
<mx:Script>
<![CDATA[
import com.bankcomm.icms.domain.migrate.Bo;
import com.bankcomm.icms.common.DataDict;
import mx.binding.utils.BindingUtils;
import mx.collections.ArrayCollection;
private var bo:Bo = new Bo();
function init():void {
autowireBindObject(bo);
}
function autowireBindCollection(arr:ArrayCollection):void {
}
function autowireBindObject(bo:Object) {
for each(var propertyName:String in bo.propertyNames) {
var elem:Object = this[bo.className + "_" + propertyName];
if(elem==null) continue;
var value = bo[propertyName];
if(elem instanceof ComboBox) {
ComboBox(elem).dataProvider = DataDict.dictYesNo;
BindingUtils.bindProperty(elem, "selectedIndex", bo, propertyName, false);
BindingUtils.bindProperty(bo, propertyName, ComboBox(elem), "selectedIndex",false);
} else if(elem instanceof TextInput) {
BindingUtils.bindProperty(elem, "text", bo, propertyName, false);
BindingUtils.bindProperty(bo, propertyName, TextInput(elem), "text", false);
} else if(elem instanceof DateField) {
BindingUtils.bindProperty(elem, "text", bo, propertyName, false);
BindingUtils.bindProperty(bo, propertyName, DateField(elem), "text", false);
} else {
}
}
}
function chageModelAndUpdateUI() {
bo.property0 = "xxx";
bo.property1 = 1;
bo.property2 = "2009-02-10";
}
function chageUIAndUpdateModel():void {
var a = bo.property1;
}
]]>
</mx:Script>
<mx:TextInput id="Bo_property0" x="65" y="10"/>
<mx:ComboBox id="Bo_property1" x="65" y="51" width="160"/>
<mx:DateField id="Bo_property2" x="65" y="92" width="160"/>
<mx:Button x="65" y="133" label="模型改变更新UI" click="chageModelAndUpdateUI();" />
<mx:Button x="179" y="133" label="UI改变更新模型" click="chageUIAndUpdateModel();" />
</mx:Application>