5 月
31
2010

mx_internal_uid Problem

這是我最近遇到的問題,因為自己寫的AMF function是吃進一個VO,然後按VO的property name對應database column存取,這邊發生一件怪事,當我把VO賦給UI物件(DataGrid)作為dataprovider時,裡面的VO多了一個mx_internal_uid屬性,導致我存入DB時發生錯誤,因為我的資料表中並沒有mx_internal_uid欄位,他就這麼輕易的弄髒我辛苦整理乾淨的VO,找到adobe reference的說明。

When Flex creates a UID for an object, such as an item in an ArrayCollection, it adds the UID as an mx_internal_uid property of the item. Flex creates mx_internal_uid properties for any objects that are dynamic and do not have bindable properties. To avoid having Flex create mx_internal_uid properties, the object class should do any of the following things: have at least one property with a [Bindable] metadata tag, implement the IUID interface, or have a uid property with a value.

目前我的作法是在Proxy取出VO的地方強制把mx_internal_uid刪除,但總覺得非常愚蠢,有空還是要刻一個VO template給他裝。

這邊又有個之前發生的怪事,我把RemoteObject取得的值當作一個data VO屬性,使用這個RemoteObject作為DataGrid的dataprovider,然後這個DataGrid將無法focus滑鼠指到的物件,上網查了一下猜想也可能是UID相同的問題,得要想辦法解決。

這邊用一個最簡單的想法─親手弄髒她!@@

在吃進VO當下就用new ObjectProxy(VO)封裝,由於ObjectProxy已經實作了get uid,所以VO不會被加上mx_internal_uid屬性,存入資料庫時就用下面的方法取回乾淨的VO

How to get Value(proxied) Object from ObjectProxy

Written by in: 電腦三兩事 | 標籤: ,

尚無留言 »

RSS feed for comments on this post. TrackBack URL


Leave a Reply

Powered by WordPress | Theme: Aeros 2.0 by TheBuckmaker.com