- 浏览: 1148808 次
- 性别:
- 来自: 北京
文章分类
- 全部博客 (411)
- Java Foundation (41)
- AI/机器学习/数据挖掘/模式识别/自然语言处理/信息检索 (2)
- 云计算/NoSQL/数据分析 (11)
- Linux (13)
- Open Source (12)
- J2EE (52)
- Data Structures (4)
- other (10)
- Dev Error (41)
- Ajax/JS/JSP/HTML5 (47)
- Oracle (68)
- FLEX (19)
- Tools (19)
- 设计模式 (4)
- Database (12)
- SQL Server (9)
- 例子程序 (4)
- mysql (2)
- Web Services (4)
- 面试 (8)
- 嵌入式/移动开发 (18)
- 软件工程/UML (15)
- C/C++ (7)
- 架构Architecture/分布式Distributed (1)
最新评论
-
a535114641:
LZ你好, 用了这个方法后子页面里的JS方法就全不能用了呀
页面局部刷新的两种方式:form+iframe 和 ajax -
di1984HIT:
学习了,真不错,做个记号啊
Machine Learning -
赵师傅临死前:
我一台老机器,myeclipse9 + FB3.5 可以正常使 ...
myeclipse 10 安装 flash builder 4.6 -
Wu_Jiang:
触发时间在将来的某个时间 但是第一次触发的时间超出了失效时间, ...
Based on configured schedule, the given trigger will never fire. -
cylove007:
找了好久,顶你
Editable Select 可编辑select
今天碰到了一个非常让我困扰的问题,使我觉得很有必要对Object的可绑定代理对象ObjectProxy做一个单独的说明;而<fx:Model>,在编译时正是会被编译为ObjectProxy类型(The most common type of MXML-based model is the <fx:Model> tag, which is compiled into an ActionScript object of type mx.utils.ObjectProxy, which contains a tree of objects when your data is in a hierarchy, with no type information. The leaves of the Object tree are scalar values)。
关于数据绑定的帖子导航:
http://wuaner.iteye.com/blog/1056650
关于 warning: unable to bind to property 'cntCt' on class 'Object' (class is not an IEventDispatcher) 导航:
http://wuaner.iteye.com/blog/1054153
问题描述:
两个级联弹出的模态窗口TitleWindow;一级窗口中有名为counterDg的datagrid,其dataProvider为名为counterAC的arrayCollection。二级窗口对一级窗口中的counterDg中数据做增删改(实际就是对counterDg的dataProvider counterAC做增删改;这里的增删改,并不会提交后台,在一级窗口被提交后才会做提交后台的动作)。最开始时,counterAC中存的是Object。
问题就出在二级窗口中对一级窗口counterDg做修改的时候:
改的时候是需要将数据带到二级窗口的,自然一级窗口counterDg.selectedItem会有向二级窗口输入域的单向绑定(这里不应该用双向绑定,因为双向绑定的话,在二级窗口中对绑定的数据做修改,会立即触发一级窗口dataGrid中当前选定行随之而改变,即使你连“提交”按钮都没点;这显然是不合逻辑的。),如:
在二级窗口点击提交按钮的方法中,集中做反向的绑定工作:使用BindingUtils动态的将页面输入域的值绑定回counter:
明明警告我说“不能绑定Object的属性xxx”,却还绑定成功了;刚要以为这个警告无关紧要,却发现绑定仅仅对counterAC起了作用,可是却不会刷新使用counterAC作为dataProvider的counterDg,这算什么个事啊。。。
既然有这样的问题存在,那就从警告入手,着手解决。通过将counterAC中放ObjectProxy对象而不是放Object对象,来解决掉这个警告:
增加时,通过addItem加到一级页面counterAC中的也应该是ObjectProxy:
至此,问题解决,一级页面dataGrid在二级页面点击确定后被成功刷新,也没有了刚才的警告。
明白了一个道理:flex中的warning不比error影响力小!千万不能置之不理!
关于ObjectProxy:
Using Flex 4.5 / Using data-driven UI components / Storing data
-> Defining a data model:
http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf69084-7b51.html#WS2db454920e96a9e51e63e3d11c0bf66ba1-7ffb
-> Using a data model as a value object:
http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf66ba1-7ff7.html
under the hood flex data model using the fx:model and fx:xml tags:
http://elromdesign.com/blog/2009/07/20/under-the-hood-flex-data-model-using-the-fxmodel-and-fxxml-tags/
通过remoteObject调用后台得到的result也可能本身就是ObjectProxy类型的,只要:
http://tech.groups.yahoo.com/group/flexcoders/message/66621
使用ObjectProxy时有个注意事项:
http://www.smithfox.com/?e=96
关于数据绑定的帖子导航:
http://wuaner.iteye.com/blog/1056650
关于 warning: unable to bind to property 'cntCt' on class 'Object' (class is not an IEventDispatcher) 导航:
http://wuaner.iteye.com/blog/1054153
问题描述:
两个级联弹出的模态窗口TitleWindow;一级窗口中有名为counterDg的datagrid,其dataProvider为名为counterAC的arrayCollection。二级窗口对一级窗口中的counterDg中数据做增删改(实际就是对counterDg的dataProvider counterAC做增删改;这里的增删改,并不会提交后台,在一级窗口被提交后才会做提交后台的动作)。最开始时,counterAC中存的是Object。
问题就出在二级窗口中对一级窗口counterDg做修改的时候:
改的时候是需要将数据带到二级窗口的,自然一级窗口counterDg.selectedItem会有向二级窗口输入域的单向绑定(这里不应该用双向绑定,因为双向绑定的话,在二级窗口中对绑定的数据做修改,会立即触发一级窗口dataGrid中当前选定行随之而改变,即使你连“提交”按钮都没点;这显然是不合逻辑的。),如:
<!-- 切记这里不适合配双向绑定 @{counter.cntOt} --> <mx:FormItem label="开放时间:"> <myDateTime:DateTimeSelectorFinal id="cntOt" selectedDate="{counter.cntOt}"/> </mx:FormItem>因为counterAC中放的是Object,二级窗口中自然也用一个Object接一级窗口dataGrid的选定项:
[Bindable] public var counter:Object;
在二级窗口点击提交按钮的方法中,集中做反向的绑定工作:使用BindingUtils动态的将页面输入域的值绑定回counter:
if(null != counter) { //修改 BindingUtils.bindProperty(counter, "cnt", cnt, ["selectedItem","data"]); BindingUtils.bindProperty(counter, "cntCls", cntCls, ["selectedItem","data"]); BindingUtils.bindProperty(counter, "cntOt", cntOt, "selectedDate"); BindingUtils.bindProperty(counter, "cntCt", cntCt, "selectedDate"); BindingUtils.bindProperty(counter, "cntPot", cntPot, "selectedDate"); BindingUtils.bindProperty(counter, "cntPct", cntPct, "selectedDate"); PopUpManager.removePopUp(this); } else { //增加 //add item into counterDg's dataProvider : counterAC this.dispatchEvent(new Event("addCounter")); }因为counter为Object类型,自然这个警告及时出现了:
warning: unable to bind to property 'cntCt' on class 'Object' (class is not an IEventDispatcher)这时候让我费解的情况发生了:尽管有上面的警告,但通过debug跟踪,发现二级页面的输入域的值还是被成功绑定到了一级TitleWindow的counterAC,counterAC的值已经变成了变化后的值;但怪就怪在:使用counterAC作为dataProvider的counterDg没有随着二级TitleWindow的关闭而自动刷新!但通过滚动counterDg的滚动条,使更新的数据行在可见区域中不可见,再滚回来后,你会发现counterDg中刚才错误的数据行变成正确的了!
明明警告我说“不能绑定Object的属性xxx”,却还绑定成功了;刚要以为这个警告无关紧要,却发现绑定仅仅对counterAC起了作用,可是却不会刷新使用counterAC作为dataProvider的counterDg,这算什么个事啊。。。
既然有这样的问题存在,那就从警告入手,着手解决。通过将counterAC中放ObjectProxy对象而不是放Object对象,来解决掉这个警告:
//counterAC初始化的改动: var counter1:Object = new Object(); counter1.xxx = "yyy"; ... counterAC.addItem(new ObjectProxy(counter1)); //由原来的直接放Object,改为放ObjectProxy //二级页面中接受一级页面dataGrid当前选定行的变量counter也改为ObjectProxy类型: [Bindable] public var counter:ObjectProxy; //一级页面修改函数在为二级页面counter赋值时也赋ObjectProxy: protected function editFidsDepfCounterHandler(event:MouseEvent):void { //DateGrid的selectedItem返回的是Object类型 var selectedItem:Object = counterDg.selectedItem; if(null == selectedItem) { Alert.show("请选择要修改的记录!"); } else { var win : AddFidsDepfCounterWindow = new AddFidsDepfCounterWindow(); win.counter = new ObjectProxy(selectedItem); win.title="修改"; PopUpManager.addPopUp(win,this,true); PopUpManager.centerPopUp(win); } }
增加时,通过addItem加到一级页面counterAC中的也应该是ObjectProxy:
引用
//二级页面中:
<fx:Declarations> <!-- <fx:Model> tag is compiled into an ActionScript object of type mx.utils.ObjectProxy --> <fx:Model id="addCounterInfo"> <counter> <cnt>{cnt.selectedItem.data}</cnt> <cntCls>{cntCls.selectedItem.data}</cntCls> <cntOt>{cntOt.selectedDate}</cntOt> <cntCt>{cntCt.selectedDate}</cntCt> <cntPot>{cntPot.selectedDate}</cntPot> <cntPct>{cntPct.selectedDate}</cntPct> </counter> </fx:Model> </fx:Declarations>//一级页面中:
protected function addFidsDepfCounterHandler(event:MouseEvent):void { var win : AddFidsDepfCounterWindow = new AddFidsDepfCounterWindow(); win.title="增加"; win.addEventListener("addCounter", saveNewCounter); PopUpManager.addPopUp(win,this,true); PopUpManager.centerPopUp(win); } protected function saveNewCounter(event:Event):void { //trace(event); var win:AddFidsDepfCounterWindow = event.target as AddFidsDepfCounterWindow; counterAC.addItem(win.addCounterInfo); //因为addCounterInfo是通过<fx:Model>定义的,所以它本省就是个ObjectProxy类型的对象 PopUpManager.removePopUp(win); }
至此,问题解决,一级页面dataGrid在二级页面点击确定后被成功刷新,也没有了刚才的警告。
明白了一个道理:flex中的warning不比error影响力小!千万不能置之不理!
关于ObjectProxy:
Using Flex 4.5 / Using data-driven UI components / Storing data
-> Defining a data model:
http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf69084-7b51.html#WS2db454920e96a9e51e63e3d11c0bf66ba1-7ffb
引用
The most common type of MXML-based model is the <fx:Model> tag, which is compiled into an ActionScript object of type mx.utils.ObjectProxy, which contains a tree of objects when your data is in a hierarchy, with no type information. The leaves of the Object tree are scalar values. Because models that are defined in <fx:Model> tags contain no type information or business logic, you should use them only for the simplest cases. Define models in ActionScript classes when you need the typed properties or you want to add business logic.
-> Using a data model as a value object:
http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf66ba1-7ff7.html
under the hood flex data model using the fx:model and fx:xml tags:
http://elromdesign.com/blog/2009/07/20/under-the-hood-flex-data-model-using-the-fxmodel-and-fxxml-tags/
通过remoteObject调用后台得到的result也可能本身就是ObjectProxy类型的,只要:
http://tech.groups.yahoo.com/group/flexcoders/message/66621
引用
You'll have to determine why an ObjectProxy is being created... typically it's because an anonymous Object was returned and RemoteObject had makeObjectsBindable="true" (which it is by default).
我的返回结果为ObjectProxy的例子:引用
java后台,返回类型是Map:
public Map<FidsDevice, List<FidsChannelRefDev>> findDevAndChannelByDevId(String devId) { return this.iFidsDeviceService.findDevAndChannelByDevId(devId); }flex前台,makeObjectsBindable="true":
<mx:RemoteObject id="iFidsDeviceFlexService" destination="iFidsDeviceFlexService" makeObjectsBindable="true"> <mx:method name="findDevAndChannelByDevId" result="devAndChannelDataHandler(event)" > <mx:arguments> <id>{updatedDevId}</id> </mx:arguments> </mx:method> </mx:RemoteObject>
使用ObjectProxy时有个注意事项:
http://www.smithfox.com/?e=96
引用
只能处理当前所代理类的直接属性, 不能感知nested field property变化, 这明显和它声明实现IPropertyChangeNotifier接口是不符的.
发表评论
-
myeclipse 10 安装 flash builder 4.6
2011-12-11 12:47 15454从Flash Builder 4 之后,ado ... -
FLEX:Nested Object & Nested Data Grid
2011-08-15 18:14 2159Flex Nested Object & Nested ... -
FLEX 服务器端交互: remoteObject & AsyncToken & 数据定时刷新 & Timer
2011-06-21 18:47 2788动态调用RemoteObject: Dynamically i ... -
FLEX : Tree & contextMenu & Array's filter & ArrayCollection's filterFunction
2011-05-29 16:05 1932Using Flex 4.5 / Using data-dri ... -
Flex:Application&Variable Scope(this owner parent parentApp parentDoc outerDoc)
2011-05-28 17:18 1433关键字: this owner parent parentA ... -
Flex : Performance tuning 性能调优
2011-05-28 14:50 1708附件: Flex Application Performanc ... -
FLEX example 例子
2011-05-28 12:12 3234How to find an ArrayCollection ... -
FLEX : Validator 验证
2011-05-26 23:57 2213Data Access and Interconnectivi ... -
FLEX : Event 事件
2011-05-24 19:51 1724ActionScript 3.0 Developer’s Gu ... -
FLEX:Data Binding 数据绑定
2011-05-24 14:44 3645务须精读的文章: Flex data binding pitf ... -
FLEX Component 组件 汇总
2011-05-23 13:56 2312Combox默认将对象中名为label的属性作为显示用的lab ... -
FLEX : dragEnabled & dropEnabled
2011-05-22 17:38 1720通过设置dragEnabled属性为true,可以使这些控件作 ... -
FLEX Data type 数据类型
2011-05-22 09:21 2092Programming ActionScript 3.0 / ... -
FLEX ERROR WARNING 总结
2011-05-22 08:13 3244常会碰到的错误:TypeError: Error #1009: ... -
Flex: labelFunction versus ItemRenderer
2011-05-22 07:16 3297When to Use labelFunction versu ... -
Flex Application 初始化顺序
2011-05-22 06:15 1670http://blog.csdn.net/chengyong ... -
Flex Metadata 元数据:Bindable(注意首字母大写),etc
2011-05-22 06:08 1782Adobe® Flex™ 3.2 语言参考 -> 元数据 ... -
FLEX笔记
2009-04-15 10:29 2347Adobe Flex 4 官方资料库: http://help ...
相关推荐
`<mx:Image>` 和 `<mx:VBox>` 控件分别显示书籍的封面图片和标题作者信息。 #### 三、使用 MXML 和 ActionScript 定义 ItemRenderer 当需要更复杂的逻辑或交互时,仅依靠 MXML 来定义 ItemRenderer 可能不够。这时...
<fx:Script> <![CDATA[ [Bindable] [Embed("../png/internet.png")] // 自定义图标路径 private var myFolderClosedIcon:Class; [Bindable] [Embed("../png/phone.png")] private var myFolderOpenIcon:...
<fx:Effect id="fadeIn" type="Fade"> <mx:duration>1000</mx:duration> </fx:Effect> <fx:EffectTarget targets="{myComponent}"/> ``` 这段代码定义了一个名为`fadeIn`的淡入效果,持续时间为1秒,并将其应用到...
该flex应用程序演示了柱状图动态切换数据源 <mx:ColumnChart x="6" y="65" id="columnchart1" showDataTips="true" dataProvider="{list}" height="390" itemClick="onItemClick(event)"> <mx:horizontalAxis> ...
<fx:Script> <![CDATA[ private function initApp():void { button.addEventListener(MouseEvent.CLICK, buttonClickHandler, true); // 捕获阶段监听 mypanel.addEventListener(MouseEvent.CLICK, ...
<fx:Object dataField1="示例数据" dataField2="示例数据" dataField3="示例数据"/> </s:typicalItem> <s:ArrayList> <fx:Object dataField1="数据1" dataField2="数据1" dataField3="数据1"/> <fx:Object data...
在Flex项目中,添加以下代码到你的MXML文件的`<fx:Declarations>`部分: ```xml <fx:Script> <![CDATA[ import mx.collections.ArrayCollection; import mx.charts.LineChart; import mx.charts.series....
<mx:Script source="include/OLAPAppInFlex.as" /> <mx:Script source="include/Chart.as" /> <mx:Script source="include/FlexBIDataGrid.as" /> <mx:Script source="include/OLAPGridConfigure.as" /> <mx:Style ...
<fx:Script> <![CDATA[ import mx.events.FlexEvent; protected var names:Array = ['Leif','Zach','Stacey','Seth','Leonard']; protected var titles:Array = ['Evangelist','Director', 'Information ...
<mx:Script> <![CDATA[ import mx.controls.CheckBox; import mx.controls.Alert; import com.as3xls.xls.ExcelFile; import com.as3xls.xls.Sheet; import flash.filesystem.*; [Bindable] private ...
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:flex="main.flex.*"> <mx:Canvas> <os:Map> <os:MaxExtent/> <os:WMS name="Germany" url=...
<fx:Declarations> <s:MenuBar id="mainMenu"> <s:menuItems> <s:MenuItem label="File"> <s:menu> <s:Menu> <s:MenuItem label="Open"/> <s:MenuItem label="Save"/> </s:Menu> </s:menu> </s:MenuItem> ...
<compa><jsp:expression>compa</jsp:expression></compa> <compb><jsp:expression>compb</jsp:expression></compb> </day> <jsp:scriptlet> <![CDATA[ } ]]> </jsp:scriptlet> </days> </jsp:root> ``` ...
<name>com.adobe.flexbuilder.project.flexbuilder</name> <arguments> </arguments> </buildCommand> </buildSpec> <natures> <nature>com.adobe.flexbuilder.project.flexnature</nature> ...
<fx:Component id="checkboxRenderer"> <mx:HBox width="100%"> <mx:CheckBox id="checkBox" label="{data.@label}"/> <mx:Label text="{data.@label}" verticalAlign="middle"/> </mx:HBox> </fx:Component> ``...
</fx:Metadata> <s:Ellipse width="100%" height="100%"> <s:fill> <s:SolidColor color="0x131313" color.over="#191919" color.down="#ffffff"/> </s:fill> <s:stroke> <s:SolidColorStroke color="0x0c0d0...
<fx:Component> <s:IconItemRenderer iconFunction="getIcon"> <s:Label text="{data.label}" /> </s:IconItemRenderer> </fx:Component> </mx:itemRenderer> </mx:List> </mx:Application> ``` 在这个例子...
- **元数据**:`<fx:Metadata>`中的`[HostComponent]`属性指定了该皮肤对应的Flex控件,这里是`spark.components.Button`。 - **UI元素布局**: - 使用`<s:Ellipse>`绘制圆形背景,并通过`<s:fill>`和`<s:stroke>...
<description>Easy to use</description> </product> <product productId="2"> <name>Nokia6020</name> <description>Easy to use</description> </product> <product productId="3"> <name>Nokia6030</name...
<fx:Declarations> <!-- 将非可视元素(例如服务、值对象)放在此处 --> </fx:Declarations> <ns1:FusionCharts id="fc" width="100%" height="100%" FCChartType="Column3D"> </ns1:FusionCharts> <fx:...