문제

I have some small problem in understanding Value Objects in Flex... I'm trying to get some data from PHP/MySQL and send it to Flex but I'm stuck in some (obviously) basic problems...

Let's say That my object in Flex would look like this:

package some.package.VO {

    [RemoteClass(alias="VOPerson")]

    [Bindable]
    public class VOPerson {
        public var personID:int;
        public var firstName:String;
        public var lastName:String;
        public var personDetails:Array;
    }
}

In my case, personDetails is an Array, and in theory, it could be some other object... But is it really necessary to make it an object? I do not intend to use that data nowhere else except within my VOPerson class. It is some associative array, and I can easily transform it to another object, but there will be lots of similar situations in my app, so I would like to avoid making unnecessary (value) objects if there is no need for it...

Anyway, any tip/hint/link about my problem would be really appreciated! :)
Thank you very much!

도움이 되었습니까?

해결책

I'm not as familiar with PHP/Flex serialization as I am with Java/Flex, but I believe the same principles will hold. If personDetails is an array of primitives, it will be serialized as such by Flex. If personDetails is a type that Flex does not know how to serialize (i.e. you haven't defined it as a RemoteClass), it will be converted to an anonymous object.

If you're trying to prevent personDetails in your PHP code from being serialized to Flex in the first place, that might be more tricky. I know that Flex identifies serializable fields in Java by looking for a public getter/setter pair, so you can prevent serialization by simply not exposing a getter and setter. There might be some similar trick you can do in PHP.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top