|
View:
New views
9 Messages
—
Rating Filter:
Alert me
|
|
|
|
|
|
Re: Class Mapping with 1.9Hi Jacob,
Personally to simplify things I would initially send back a simplified Person object with no 'children' property (ie. remove the property from the class in both AS and PHP) to see if the mapping is working correctly. The reason is that PHP does not have an ArrayCollection type so having this as the type of 'children' on the AS side may be confusing the mapping. Get this working first and then move on to the ArrayCollection problem. You could tell if the mapping is working on this simplified Person object as this code will throw an error if it's not: public function result(data:Object):void { var thisPerson:Person = data.result; } For the ArrayCollection problem, you can either make the 'children' object of type Array on both the AS and PHP sides or create a custom ArrayCollection type on the PHP side. Here's an example of this: http://old.nabble.com/Coercion-failed-ArrayCollection-with-Objects-inside-Ob ject-AMFPHP-1.9-to9594166.html Some more info on AMFPHP and ArrayCollections here: http://wadearnold.com/blog/flash/amfphp/amfphp-arraycollection Lastly, this part of your code looks a bit weird: $array->children = new Person(); $array->children->name[] = 'two'; $array->children->name[] = 'three'; 'children' is defined as an ArrayCollection in your AS class but you've assigned a Person object to it here. Also, 'name' is a string but you're treating like an Array. I hope this helps. My advice is to start with the simplest example and then work from there. Cheers, Darren. On 27/2/10 6:35 AM, "Jacob Steinberger" <trefalgar@...> wrote: > First, apologies for breaking threading. I don't have the email I want > to reply to, available to reply to =\ > > Darren, thanks for your comments. My output from PHP now looks like thus: > > Person Object > ( > [name] => one > [children] => ArrayCollection Object > ( > [_explicitType] => mx.collections.ArrayCollection > [source] => Array > ( > [0] => Person Object > ( > [name] => two > [children] => > [_explicitType] => Person > ) > > [1] => Person Object > ( > [name] => three > [children] => > [_explicitType] => Person > ) > > ) > > ) > > [_explicitType] => Person > ) > > It looks pretty good. But when I view it during a debug session within > Flex Builder, it shows up as stock arrays or objects (not as the VO). > Is this the expected result? What test can be done on the data inside > Flex to show that it was converted to Flex's VOs? > > I'm familiar with Charles, Wireshark, etc, and the data appears good > there. But again, when the data gets to Flex, it doesn't seem right. > > Jacob > > Quoting trefalgar@...: > >> I've searched the internet, read at least a dozen blogs and tried a ton of >> variations of code to get class mapping to work. None of it does. It seems >> the vast majority of examples on the internet are code snippets, pieces and >> fragments - all with comments asking for a full code block because the >> examples aren't complete. >> >> I hope this list is the proper place to ask this kind of question as I'm >> at my wits end. I'd like to get this working and post a full example to the >> internet (even if I don't get indexed) just to have a place to point other >> people to that are having the same problem. >> >> php, services/vo: >> class Person { >> public $name; >> public $children; >> >> var $_explicitType="vo.Person"; >> function Person(){ >> } >> } >> >> php, services: >> function test3() { >> $array = new Person(); >> $array->name = 'one'; >> $array->children = new Person(); >> $array->children->name[] = 'two'; >> $array->children->name[] = 'three'; >> #$array['_explicitType'] = 'vo.Person'; >> #registerClassAlias("vo.Person",Person); >> return($array); >> } >> >> Person.as: >> package vo { >> import mx.collections.ArrayCollection; >> [Bindable][RemoteClass(alias="vo.Person")] >> public class Person{ >> >> public var name:String; >> public var children:ArrayCollection; >> >> public function Person(_name:String, _children:ArrayCollection = >> null){ >> this.name = _name; >> if(_children != null) >> this.children = _children; >> }//end Person constructor >> >> }//end Person class >> >> }//end package declaration >> >> I've tried every combination of _explicitType, registerClassAlias, and >> RemoteClass I've read about. Some sources say you need one, some say you >> need two, one even said you need all three. >> >> I'd appreciate any recommendation or pointing me to a working example that >> I could look at to see how it works for *someone*. >> >> Jacob >> > > > > > ------------------------------------------------------------------------------ > Download Intel® Parallel Studio Eval > Try the new software tools for yourself. Speed compiling, find bugs > proactively, and fine-tune applications for parallel performance. > See why Intel Parallel Studio got high marks during beta. > http://p.sf.net/sfu/intel-sw-dev > _______________________________________________ > amfphp-general mailing list > amfphp-general@... > https://lists.sourceforge.net/lists/listinfo/amfphp-general ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev _______________________________________________ amfphp-general mailing list amfphp-general@... https://lists.sourceforge.net/lists/listinfo/amfphp-general |
|
|
Re: Class Mapping with 1.9I'll try the simple path, but I appear to have skipped something in my
last post. With your previous suggestions, I got the output of the first 'Person' working in PHP, then I went forward with adding the ArrayCollection. That's when I posted the results. The current PHP looks like ... $array = new Person('one', new ArrayCollection(array(new Person('two'), new Person('three')))); ... which hopefully looks better than my previous PHP snippet. Again, I'll try the simple path with just sending a Person with no ArrayCollection and see if that works. Jacob Quoting Darren Smith <dazquick@...>: > Hi Jacob, > > Personally to simplify things I would initially send back a simplified > Person object with no 'children' property (ie. remove the property from the > class in both AS and PHP) to see if the mapping is working correctly. The > reason is that PHP does not have an ArrayCollection type so having this as > the type of 'children' on the AS side may be confusing the mapping. Get this > working first and then move on to the ArrayCollection problem. You could > tell if the mapping is working on this simplified Person object as this code > will throw an error if it's not: > > public function result(data:Object):void { > var thisPerson:Person = data.result; > } > > For the ArrayCollection problem, you can either make the 'children' object > of type Array on both the AS and PHP sides or create a custom > ArrayCollection type on the PHP side. Here's an example of this: > > http://old.nabble.com/Coercion-failed-ArrayCollection-with-Objects-inside-Ob > ject-AMFPHP-1.9-to9594166.html > > Some more info on AMFPHP and ArrayCollections here: > > http://wadearnold.com/blog/flash/amfphp/amfphp-arraycollection > > Lastly, this part of your code looks a bit weird: > > $array->children = new Person(); > $array->children->name[] = 'two'; > $array->children->name[] = 'three'; > > 'children' is defined as an ArrayCollection in your AS class but you've > assigned a Person object to it here. Also, 'name' is a string but you're > treating like an Array. > > I hope this helps. My advice is to start with the simplest example and then > work from there. > > Cheers, > Darren. > > On 27/2/10 6:35 AM, "Jacob Steinberger" <trefalgar@...> wrote: > >> First, apologies for breaking threading. I don't have the email I want >> to reply to, available to reply to =\ >> >> Darren, thanks for your comments. My output from PHP now looks like thus: >> >> Person Object >> ( >> [name] => one >> [children] => ArrayCollection Object >> ( >> [_explicitType] => mx.collections.ArrayCollection >> [source] => Array >> ( >> [0] => Person Object >> ( >> [name] => two >> [children] => >> [_explicitType] => Person >> ) >> >> [1] => Person Object >> ( >> [name] => three >> [children] => >> [_explicitType] => Person >> ) >> >> ) >> >> ) >> >> [_explicitType] => Person >> ) >> >> It looks pretty good. But when I view it during a debug session within >> Flex Builder, it shows up as stock arrays or objects (not as the VO). >> Is this the expected result? What test can be done on the data inside >> Flex to show that it was converted to Flex's VOs? >> >> I'm familiar with Charles, Wireshark, etc, and the data appears good >> there. But again, when the data gets to Flex, it doesn't seem right. >> >> Jacob >> >> Quoting trefalgar@...: >> >>> I've searched the internet, read at least a dozen blogs and tried a ton of >>> variations of code to get class mapping to work. None of it does. It seems >>> the vast majority of examples on the internet are code snippets, pieces and >>> fragments - all with comments asking for a full code block because the >>> examples aren't complete. >>> >>> I hope this list is the proper place to ask this kind of question as I'm >>> at my wits end. I'd like to get this working and post a full example to the >>> internet (even if I don't get indexed) just to have a place to point other >>> people to that are having the same problem. >>> >>> php, services/vo: >>> class Person { >>> public $name; >>> public $children; >>> >>> var $_explicitType="vo.Person"; >>> function Person(){ >>> } >>> } >>> >>> php, services: >>> function test3() { >>> $array = new Person(); >>> $array->name = 'one'; >>> $array->children = new Person(); >>> $array->children->name[] = 'two'; >>> $array->children->name[] = 'three'; >>> #$array['_explicitType'] = 'vo.Person'; >>> #registerClassAlias("vo.Person",Person); >>> return($array); >>> } >>> >>> Person.as: >>> package vo { >>> import mx.collections.ArrayCollection; >>> [Bindable][RemoteClass(alias="vo.Person")] >>> public class Person{ >>> >>> public var name:String; >>> public var children:ArrayCollection; >>> >>> public function Person(_name:String, _children:ArrayCollection = >>> null){ >>> this.name = _name; >>> if(_children != null) >>> this.children = _children; >>> }//end Person constructor >>> >>> }//end Person class >>> >>> }//end package declaration >>> >>> I've tried every combination of _explicitType, registerClassAlias, and >>> RemoteClass I've read about. Some sources say you need one, some say you >>> need two, one even said you need all three. >>> >>> I'd appreciate any recommendation or pointing me to a working example that >>> I could look at to see how it works for *someone*. >>> >>> Jacob >>> >> >> >> >> >> ------------------------------------------------------------------------------ >> Download Intel® Parallel Studio Eval >> Try the new software tools for yourself. Speed compiling, find bugs >> proactively, and fine-tune applications for parallel performance. >> See why Intel Parallel Studio got high marks during beta. >> http://p.sf.net/sfu/intel-sw-dev >> _______________________________________________ >> amfphp-general mailing list >> amfphp-general@... >> https://lists.sourceforge.net/lists/listinfo/amfphp-general > > > > ------------------------------------------------------------------------------ > Download Intel® Parallel Studio Eval > Try the new software tools for yourself. Speed compiling, find bugs > proactively, and fine-tune applications for parallel performance. > See why Intel Parallel Studio got high marks during beta. > http://p.sf.net/sfu/intel-sw-dev > _______________________________________________ > amfphp-general mailing list > amfphp-general@... > https://lists.sourceforge.net/lists/listinfo/amfphp-general > ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev _______________________________________________ amfphp-general mailing list amfphp-general@... https://lists.sourceforge.net/lists/listinfo/amfphp-general |
|
|
Re: Class Mapping with 1.9Flex Builder doesn't like setting event.result to anything other than
an Object. I assume that's expected. I buried the Person into event.result.data, and it cam through as a vo.Person without any problems. It doesn't like my ArrayCollection, but it's progress! Thanks for the help Darren, Jacob Quoting Jacob Steinberger <trefalgar@...>: > I'll try the simple path, but I appear to have skipped something in my > last post. With your previous suggestions, I got the output of the > first 'Person' working in PHP, then I went forward with adding the > ArrayCollection. That's when I posted the results. The current PHP > looks like ... > > $array = new Person('one', new ArrayCollection(array(new > Person('two'), new Person('three')))); > > ... which hopefully looks better than my previous PHP snippet. > > Again, I'll try the simple path with just sending a Person with no > ArrayCollection and see if that works. > > Jacob > > Quoting Darren Smith <dazquick@...>: > >> Hi Jacob, >> >> Personally to simplify things I would initially send back a simplified >> Person object with no 'children' property (ie. remove the property from the >> class in both AS and PHP) to see if the mapping is working correctly. The >> reason is that PHP does not have an ArrayCollection type so having this as >> the type of 'children' on the AS side may be confusing the mapping. Get this >> working first and then move on to the ArrayCollection problem. You could >> tell if the mapping is working on this simplified Person object as this code >> will throw an error if it's not: >> >> public function result(data:Object):void { >> var thisPerson:Person = data.result; >> } >> >> For the ArrayCollection problem, you can either make the 'children' object >> of type Array on both the AS and PHP sides or create a custom >> ArrayCollection type on the PHP side. Here's an example of this: >> >> http://old.nabble.com/Coercion-failed-ArrayCollection-with-Objects-inside-Ob >> ject-AMFPHP-1.9-to9594166.html >> >> Some more info on AMFPHP and ArrayCollections here: >> >> http://wadearnold.com/blog/flash/amfphp/amfphp-arraycollection >> >> Lastly, this part of your code looks a bit weird: >> >> $array->children = new Person(); >> $array->children->name[] = 'two'; >> $array->children->name[] = 'three'; >> >> 'children' is defined as an ArrayCollection in your AS class but you've >> assigned a Person object to it here. Also, 'name' is a string but you're >> treating like an Array. >> >> I hope this helps. My advice is to start with the simplest example and then >> work from there. >> >> Cheers, >> Darren. >> >> On 27/2/10 6:35 AM, "Jacob Steinberger" <trefalgar@...> wrote: >> >>> First, apologies for breaking threading. I don't have the email I want >>> to reply to, available to reply to =\ >>> >>> Darren, thanks for your comments. My output from PHP now looks like thus: >>> >>> Person Object >>> ( >>> [name] => one >>> [children] => ArrayCollection Object >>> ( >>> [_explicitType] => mx.collections.ArrayCollection >>> [source] => Array >>> ( >>> [0] => Person Object >>> ( >>> [name] => two >>> [children] => >>> [_explicitType] => Person >>> ) >>> >>> [1] => Person Object >>> ( >>> [name] => three >>> [children] => >>> [_explicitType] => Person >>> ) >>> >>> ) >>> >>> ) >>> >>> [_explicitType] => Person >>> ) >>> >>> It looks pretty good. But when I view it during a debug session within >>> Flex Builder, it shows up as stock arrays or objects (not as the VO). >>> Is this the expected result? What test can be done on the data inside >>> Flex to show that it was converted to Flex's VOs? >>> >>> I'm familiar with Charles, Wireshark, etc, and the data appears good >>> there. But again, when the data gets to Flex, it doesn't seem right. >>> >>> Jacob >>> >>> Quoting trefalgar@...: >>> >>>> I've searched the internet, read at least a dozen blogs and tried a ton of >>>> variations of code to get class mapping to work. None of it does. It seems >>>> the vast majority of examples on the internet are code snippets, >>>> pieces and >>>> fragments - all with comments asking for a full code block because the >>>> examples aren't complete. >>>> >>>> I hope this list is the proper place to ask this kind of question as I'm >>>> at my wits end. I'd like to get this working and post a full >>>> example to the >>>> internet (even if I don't get indexed) just to have a place to point other >>>> people to that are having the same problem. >>>> >>>> php, services/vo: >>>> class Person { >>>> public $name; >>>> public $children; >>>> >>>> var $_explicitType="vo.Person"; >>>> function Person(){ >>>> } >>>> } >>>> >>>> php, services: >>>> function test3() { >>>> $array = new Person(); >>>> $array->name = 'one'; >>>> $array->children = new Person(); >>>> $array->children->name[] = 'two'; >>>> $array->children->name[] = 'three'; >>>> #$array['_explicitType'] = 'vo.Person'; >>>> #registerClassAlias("vo.Person",Person); >>>> return($array); >>>> } >>>> >>>> Person.as: >>>> package vo { >>>> import mx.collections.ArrayCollection; >>>> [Bindable][RemoteClass(alias="vo.Person")] >>>> public class Person{ >>>> >>>> public var name:String; >>>> public var children:ArrayCollection; >>>> >>>> public function Person(_name:String, _children:ArrayCollection = >>>> null){ >>>> this.name = _name; >>>> if(_children != null) >>>> this.children = _children; >>>> }//end Person constructor >>>> >>>> }//end Person class >>>> >>>> }//end package declaration >>>> >>>> I've tried every combination of _explicitType, registerClassAlias, and >>>> RemoteClass I've read about. Some sources say you need one, some say you >>>> need two, one even said you need all three. >>>> >>>> I'd appreciate any recommendation or pointing me to a working example that >>>> I could look at to see how it works for *someone*. >>>> >>>> Jacob >>>> >>> >>> >>> >>> >>> ------------------------------------------------------------------------------ >>> Download Intel® Parallel Studio Eval >>> Try the new software tools for yourself. Speed compiling, find bugs >>> proactively, and fine-tune applications for parallel performance. >>> See why Intel Parallel Studio got high marks during beta. >>> http://p.sf.net/sfu/intel-sw-dev >>> _______________________________________________ >>> amfphp-general mailing list >>> amfphp-general@... >>> https://lists.sourceforge.net/lists/listinfo/amfphp-general >> >> >> >> ------------------------------------------------------------------------------ >> Download Intel® Parallel Studio Eval >> Try the new software tools for yourself. Speed compiling, find bugs >> proactively, and fine-tune applications for parallel performance. >> See why Intel Parallel Studio got high marks during beta. >> http://p.sf.net/sfu/intel-sw-dev >> _______________________________________________ >> amfphp-general mailing list >> amfphp-general@... >> https://lists.sourceforge.net/lists/listinfo/amfphp-general >> > > > > > ------------------------------------------------------------------------------ > Download Intel® Parallel Studio Eval > Try the new software tools for yourself. Speed compiling, find bugs > proactively, and fine-tune applications for parallel performance. > See why Intel Parallel Studio got high marks during beta. > http://p.sf.net/sfu/intel-sw-dev > _______________________________________________ > amfphp-general mailing list > amfphp-general@... > https://lists.sourceforge.net/lists/listinfo/amfphp-general > ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev _______________________________________________ amfphp-general mailing list amfphp-general@... https://lists.sourceforge.net/lists/listinfo/amfphp-general |
|
|
Re: Class Mapping with 1.9Hi Jacob,
I haven't needed to send ArrayCollections myself (Arrays have always sufficed) but I think your PHP ArrayCollection has to map exactly to the Flex version, in particular the 'source' property of an ArrayCollection object should be set to an Array. Maybe try this: php, services/vo/mx/collections: class ArrayCollection { var $source; var $_explicitType = "mx.collections.ArrayCollection"; } And create your 'children' ArrayCollection with: var $child_array = array(); $child_array[] = new Person(); $child_array[] = new Person(); var $children = new ArrayCollection(); $children->source = $child_array; It will probably be something like this although I noticed that in the thread I linked to earlier the '_explicitType' is set to 'flex.messaging.io.ArrayCollection' and the author claims that this works for him. http://old.nabble.com/Coercion-failed-ArrayCollection-with-Objects-inside-Object-AMFPHP-1.9-to9594166.html Good luck, Darren. On 2/03/2010 3:04 AM, Jacob Steinberger wrote: > Flex Builder doesn't like setting event.result to anything other than > an Object. I assume that's expected. I buried the Person into > event.result.data, and it cam through as a vo.Person without any > problems. > > It doesn't like my ArrayCollection, but it's progress! > > Thanks for the help Darren, > > Jacob > > Quoting Jacob Steinberger<trefalgar@...>: > > >> I'll try the simple path, but I appear to have skipped something in my >> last post. With your previous suggestions, I got the output of the >> first 'Person' working in PHP, then I went forward with adding the >> ArrayCollection. That's when I posted the results. The current PHP >> looks like ... >> >> $array = new Person('one', new ArrayCollection(array(new >> Person('two'), new Person('three')))); >> >> ... which hopefully looks better than my previous PHP snippet. >> >> Again, I'll try the simple path with just sending a Person with no >> ArrayCollection and see if that works. >> >> Jacob >> >> Quoting Darren Smith<dazquick@...>: >> >> >>> Hi Jacob, >>> >>> Personally to simplify things I would initially send back a simplified >>> Person object with no 'children' property (ie. remove the property from the >>> class in both AS and PHP) to see if the mapping is working correctly. The >>> reason is that PHP does not have an ArrayCollection type so having this as >>> the type of 'children' on the AS side may be confusing the mapping. Get this >>> working first and then move on to the ArrayCollection problem. You could >>> tell if the mapping is working on this simplified Person object as this code >>> will throw an error if it's not: >>> >>> public function result(data:Object):void { >>> var thisPerson:Person = data.result; >>> } >>> >>> For the ArrayCollection problem, you can either make the 'children' object >>> of type Array on both the AS and PHP sides or create a custom >>> ArrayCollection type on the PHP side. Here's an example of this: >>> >>> http://old.nabble.com/Coercion-failed-ArrayCollection-with-Objects-inside-Ob >>> ject-AMFPHP-1.9-to9594166.html >>> >>> Some more info on AMFPHP and ArrayCollections here: >>> >>> http://wadearnold.com/blog/flash/amfphp/amfphp-arraycollection >>> >>> Lastly, this part of your code looks a bit weird: >>> >>> $array->children = new Person(); >>> $array->children->name[] = 'two'; >>> $array->children->name[] = 'three'; >>> >>> 'children' is defined as an ArrayCollection in your AS class but you've >>> assigned a Person object to it here. Also, 'name' is a string but you're >>> treating like an Array. >>> >>> I hope this helps. My advice is to start with the simplest example and then >>> work from there. >>> >>> Cheers, >>> Darren. >>> >>> On 27/2/10 6:35 AM, "Jacob Steinberger"<trefalgar@...> wrote: >>> >>> >>>> First, apologies for breaking threading. I don't have the email I want >>>> to reply to, available to reply to =\ >>>> >>>> Darren, thanks for your comments. My output from PHP now looks like thus: >>>> >>>> Person Object >>>> ( >>>> [name] => one >>>> [children] => ArrayCollection Object >>>> ( >>>> [_explicitType] => mx.collections.ArrayCollection >>>> [source] => Array >>>> ( >>>> [0] => Person Object >>>> ( >>>> [name] => two >>>> [children] => >>>> [_explicitType] => Person >>>> ) >>>> >>>> [1] => Person Object >>>> ( >>>> [name] => three >>>> [children] => >>>> [_explicitType] => Person >>>> ) >>>> >>>> ) >>>> >>>> ) >>>> >>>> [_explicitType] => Person >>>> ) >>>> >>>> It looks pretty good. But when I view it during a debug session within >>>> Flex Builder, it shows up as stock arrays or objects (not as the VO). >>>> Is this the expected result? What test can be done on the data inside >>>> Flex to show that it was converted to Flex's VOs? >>>> >>>> I'm familiar with Charles, Wireshark, etc, and the data appears good >>>> there. But again, when the data gets to Flex, it doesn't seem right. >>>> >>>> Jacob >>>> >>>> Quoting trefalgar@...: >>>> >>>> >>>>> I've searched the internet, read at least a dozen blogs and tried a ton of >>>>> variations of code to get class mapping to work. None of it does. It seems >>>>> the vast majority of examples on the internet are code snippets, >>>>> pieces and >>>>> fragments - all with comments asking for a full code block because the >>>>> examples aren't complete. >>>>> >>>>> I hope this list is the proper place to ask this kind of question as I'm >>>>> at my wits end. I'd like to get this working and post a full >>>>> example to the >>>>> internet (even if I don't get indexed) just to have a place to point other >>>>> people to that are having the same problem. >>>>> >>>>> php, services/vo: >>>>> class Person { >>>>> public $name; >>>>> public $children; >>>>> >>>>> var $_explicitType="vo.Person"; >>>>> function Person(){ >>>>> } >>>>> } >>>>> >>>>> php, services: >>>>> function test3() { >>>>> $array = new Person(); >>>>> $array->name = 'one'; >>>>> $array->children = new Person(); >>>>> $array->children->name[] = 'two'; >>>>> $array->children->name[] = 'three'; >>>>> #$array['_explicitType'] = 'vo.Person'; >>>>> #registerClassAlias("vo.Person",Person); >>>>> return($array); >>>>> } >>>>> >>>>> Person.as: >>>>> package vo { >>>>> import mx.collections.ArrayCollection; >>>>> [Bindable][RemoteClass(alias="vo.Person")] >>>>> public class Person{ >>>>> >>>>> public var name:String; >>>>> public var children:ArrayCollection; >>>>> >>>>> public function Person(_name:String, _children:ArrayCollection = >>>>> null){ >>>>> this.name = _name; >>>>> if(_children != null) >>>>> this.children = _children; >>>>> }//end Person constructor >>>>> >>>>> }//end Person class >>>>> >>>>> }//end package declaration >>>>> >>>>> I've tried every combination of _explicitType, registerClassAlias, and >>>>> RemoteClass I've read about. Some sources say you need one, some say you >>>>> need two, one even said you need all three. >>>>> >>>>> I'd appreciate any recommendation or pointing me to a working example that >>>>> I could look at to see how it works for *someone*. >>>>> >>>>> Jacob >>>>> >>>>> >>>> >>>> >>>> >>>> ------------------------------------------------------------------------------ >>>> Download Intel® Parallel Studio Eval >>>> Try the new software tools for yourself. Speed compiling, find bugs >>>> proactively, and fine-tune applications for parallel performance. >>>> See why Intel Parallel Studio got high marks during beta. >>>> http://p.sf.net/sfu/intel-sw-dev >>>> _______________________________________________ >>>> amfphp-general mailing list >>>> amfphp-general@... >>>> https://lists.sourceforge.net/lists/listinfo/amfphp-general >>>> >>> >>> >>> ------------------------------------------------------------------------------ >>> Download Intel® Parallel Studio Eval >>> Try the new software tools for yourself. Speed compiling, find bugs >>> proactively, and fine-tune applications for parallel performance. >>> See why Intel Parallel Studio got high marks during beta. >>> http://p.sf.net/sfu/intel-sw-dev >>> _______________________________________________ >>> amfphp-general mailing list >>> amfphp-general@... >>> https://lists.sourceforge.net/lists/listinfo/amfphp-general >>> >>> >> >> >> >> ------------------------------------------------------------------------------ >> Download Intel® Parallel Studio Eval >> Try the new software tools for yourself. Speed compiling, find bugs >> proactively, and fine-tune applications for parallel performance. >> See why Intel Parallel Studio got high marks during beta. >> http://p.sf.net/sfu/intel-sw-dev >> _______________________________________________ >> amfphp-general mailing list >> amfphp-general@... >> https://lists.sourceforge.net/lists/listinfo/amfphp-general >> >> > > > > ------------------------------------------------------------------------------ > Download Intel® Parallel Studio Eval > Try the new software tools for yourself. Speed compiling, find bugs > proactively, and fine-tune applications for parallel performance. > See why Intel Parallel Studio got high marks during beta. > http://p.sf.net/sfu/intel-sw-dev > _______________________________________________ > amfphp-general mailing list > amfphp-general@... > https://lists.sourceforge.net/lists/listinfo/amfphp-general > ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev _______________________________________________ amfphp-general mailing list amfphp-general@... https://lists.sourceforge.net/lists/listinfo/amfphp-general |
|
|
Re: Class Mapping with 1.9ArrayCollection was the easy part, to be honest. I have two
applications, both contain the same code, on contains a lot of other crap. In the "minimal" program, everything works. In the "full blown" program the ArrayCollections come through, but the Person does not (in effect, I end up with a bunch of Objects with ArrayCollections with Objects). Pulling my hair out over it, but I'm sure it's something stupid somewhere ... As far as the RemoteBind for ArrayCollection, flex.messaging.io.ArrayCollection is correct. mx.collections.ArrayCollection is how you import ArrayCollection, but in the definition of ArrayCollection, it has a RemoteBind for the flex.messaging. Seems counter intuitive to rename things like that, but, meh! Jacob Quoting Darren Smith <dazquick@...>: > Hi Jacob, > > I haven't needed to send ArrayCollections myself (Arrays have always > sufficed) but I think your PHP ArrayCollection has to map exactly to the > Flex version, in particular the 'source' property of an ArrayCollection > object should be set to an Array. Maybe try this: > > php, services/vo/mx/collections: > class ArrayCollection { > var $source; > var $_explicitType = "mx.collections.ArrayCollection"; > } > > And create your 'children' ArrayCollection with: > > var $child_array = array(); > $child_array[] = new Person(); > $child_array[] = new Person(); > var $children = new ArrayCollection(); > $children->source = $child_array; > > It will probably be something like this although I noticed that in the > thread I linked to earlier the '_explicitType' is set to > 'flex.messaging.io.ArrayCollection' and the author claims that this > works for him. > > http://old.nabble.com/Coercion-failed-ArrayCollection-with-Objects-inside-Object-AMFPHP-1.9-to9594166.html > > Good luck, > Darren. > > On 2/03/2010 3:04 AM, Jacob Steinberger wrote: >> Flex Builder doesn't like setting event.result to anything other than >> an Object. I assume that's expected. I buried the Person into >> event.result.data, and it cam through as a vo.Person without any >> problems. >> >> It doesn't like my ArrayCollection, but it's progress! >> >> Thanks for the help Darren, >> >> Jacob >> >> Quoting Jacob Steinberger<trefalgar@...>: >> >> >>> I'll try the simple path, but I appear to have skipped something in my >>> last post. With your previous suggestions, I got the output of the >>> first 'Person' working in PHP, then I went forward with adding the >>> ArrayCollection. That's when I posted the results. The current PHP >>> looks like ... >>> >>> $array = new Person('one', new ArrayCollection(array(new >>> Person('two'), new Person('three')))); >>> >>> ... which hopefully looks better than my previous PHP snippet. >>> >>> Again, I'll try the simple path with just sending a Person with no >>> ArrayCollection and see if that works. >>> >>> Jacob >>> >>> Quoting Darren Smith<dazquick@...>: >>> >>> >>>> Hi Jacob, >>>> >>>> Personally to simplify things I would initially send back a simplified >>>> Person object with no 'children' property (ie. remove the >>>> property from the >>>> class in both AS and PHP) to see if the mapping is working correctly. The >>>> reason is that PHP does not have an ArrayCollection type so having this as >>>> the type of 'children' on the AS side may be confusing the >>>> mapping. Get this >>>> working first and then move on to the ArrayCollection problem. You could >>>> tell if the mapping is working on this simplified Person object >>>> as this code >>>> will throw an error if it's not: >>>> >>>> public function result(data:Object):void { >>>> var thisPerson:Person = data.result; >>>> } >>>> >>>> For the ArrayCollection problem, you can either make the 'children' object >>>> of type Array on both the AS and PHP sides or create a custom >>>> ArrayCollection type on the PHP side. Here's an example of this: >>>> >>>> http://old.nabble.com/Coercion-failed-ArrayCollection-with-Objects-inside-Ob >>>> ject-AMFPHP-1.9-to9594166.html >>>> >>>> Some more info on AMFPHP and ArrayCollections here: >>>> >>>> http://wadearnold.com/blog/flash/amfphp/amfphp-arraycollection >>>> >>>> Lastly, this part of your code looks a bit weird: >>>> >>>> $array->children = new Person(); >>>> $array->children->name[] = 'two'; >>>> $array->children->name[] = 'three'; >>>> >>>> 'children' is defined as an ArrayCollection in your AS class but you've >>>> assigned a Person object to it here. Also, 'name' is a string but you're >>>> treating like an Array. >>>> >>>> I hope this helps. My advice is to start with the simplest >>>> example and then >>>> work from there. >>>> >>>> Cheers, >>>> Darren. >>>> >>>> On 27/2/10 6:35 AM, "Jacob >>>> Steinberger"<trefalgar@...> wrote: >>>> >>>> >>>>> First, apologies for breaking threading. I don't have the email I want >>>>> to reply to, available to reply to =\ >>>>> >>>>> Darren, thanks for your comments. My output from PHP now looks like thus: >>>>> >>>>> Person Object >>>>> ( >>>>> [name] => one >>>>> [children] => ArrayCollection Object >>>>> ( >>>>> [_explicitType] => mx.collections.ArrayCollection >>>>> [source] => Array >>>>> ( >>>>> [0] => Person Object >>>>> ( >>>>> [name] => two >>>>> [children] => >>>>> [_explicitType] => Person >>>>> ) >>>>> >>>>> [1] => Person Object >>>>> ( >>>>> [name] => three >>>>> [children] => >>>>> [_explicitType] => Person >>>>> ) >>>>> >>>>> ) >>>>> >>>>> ) >>>>> >>>>> [_explicitType] => Person >>>>> ) >>>>> >>>>> It looks pretty good. But when I view it during a debug session within >>>>> Flex Builder, it shows up as stock arrays or objects (not as the VO). >>>>> Is this the expected result? What test can be done on the data inside >>>>> Flex to show that it was converted to Flex's VOs? >>>>> >>>>> I'm familiar with Charles, Wireshark, etc, and the data appears good >>>>> there. But again, when the data gets to Flex, it doesn't seem right. >>>>> >>>>> Jacob >>>>> >>>>> Quoting trefalgar@...: >>>>> >>>>> >>>>>> I've searched the internet, read at least a dozen blogs and >>>>>> tried a ton of >>>>>> variations of code to get class mapping to work. None of it >>>>>> does. It seems >>>>>> the vast majority of examples on the internet are code snippets, >>>>>> pieces and >>>>>> fragments - all with comments asking for a full code block because the >>>>>> examples aren't complete. >>>>>> >>>>>> I hope this list is the proper place to ask this kind of question as I'm >>>>>> at my wits end. I'd like to get this working and post a full >>>>>> example to the >>>>>> internet (even if I don't get indexed) just to have a place to >>>>>> point other >>>>>> people to that are having the same problem. >>>>>> >>>>>> php, services/vo: >>>>>> class Person { >>>>>> public $name; >>>>>> public $children; >>>>>> >>>>>> var $_explicitType="vo.Person"; >>>>>> function Person(){ >>>>>> } >>>>>> } >>>>>> >>>>>> php, services: >>>>>> function test3() { >>>>>> $array = new Person(); >>>>>> $array->name = 'one'; >>>>>> $array->children = new Person(); >>>>>> $array->children->name[] = 'two'; >>>>>> $array->children->name[] = 'three'; >>>>>> #$array['_explicitType'] = 'vo.Person'; >>>>>> #registerClassAlias("vo.Person",Person); >>>>>> return($array); >>>>>> } >>>>>> >>>>>> Person.as: >>>>>> package vo { >>>>>> import mx.collections.ArrayCollection; >>>>>> [Bindable][RemoteClass(alias="vo.Person")] >>>>>> public class Person{ >>>>>> >>>>>> public var name:String; >>>>>> public var children:ArrayCollection; >>>>>> >>>>>> public function Person(_name:String, >>>>>> _children:ArrayCollection = >>>>>> null){ >>>>>> this.name = _name; >>>>>> if(_children != null) >>>>>> this.children = _children; >>>>>> }//end Person constructor >>>>>> >>>>>> }//end Person class >>>>>> >>>>>> }//end package declaration >>>>>> >>>>>> I've tried every combination of _explicitType, registerClassAlias, and >>>>>> RemoteClass I've read about. Some sources say you need one, some say you >>>>>> need two, one even said you need all three. >>>>>> >>>>>> I'd appreciate any recommendation or pointing me to a working >>>>>> example that >>>>>> I could look at to see how it works for *someone*. >>>>>> >>>>>> Jacob >>>>>> >>>>>> >>>>> >>>>> >>>>> >>>>> ------------------------------------------------------------------------------ >>>>> Download Intel® Parallel Studio Eval >>>>> Try the new software tools for yourself. Speed compiling, find bugs >>>>> proactively, and fine-tune applications for parallel performance. >>>>> See why Intel Parallel Studio got high marks during beta. >>>>> http://p.sf.net/sfu/intel-sw-dev >>>>> _______________________________________________ >>>>> amfphp-general mailing list >>>>> amfphp-general@... >>>>> https://lists.sourceforge.net/lists/listinfo/amfphp-general >>>>> >>>> >>>> >>>> ------------------------------------------------------------------------------ >>>> Download Intel® Parallel Studio Eval >>>> Try the new software tools for yourself. Speed compiling, find bugs >>>> proactively, and fine-tune applications for parallel performance. >>>> See why Intel Parallel Studio got high marks during beta. >>>> http://p.sf.net/sfu/intel-sw-dev >>>> _______________________________________________ >>>> amfphp-general mailing list >>>> amfphp-general@... >>>> https://lists.sourceforge.net/lists/listinfo/amfphp-general >>>> >>>> >>> >>> >>> >>> ------------------------------------------------------------------------------ >>> Download Intel® Parallel Studio Eval >>> Try the new software tools for yourself. Speed compiling, find bugs >>> proactively, and fine-tune applications for parallel performance. >>> See why Intel Parallel Studio got high marks during beta. >>> http://p.sf.net/sfu/intel-sw-dev >>> _______________________________________________ >>> amfphp-general mailing list >>> amfphp-general@... >>> https://lists.sourceforge.net/lists/listinfo/amfphp-general >>> >>> >> >> >> >> ------------------------------------------------------------------------------ >> Download Intel® Parallel Studio Eval >> Try the new software tools for yourself. Speed compiling, find bugs >> proactively, and fine-tune applications for parallel performance. >> See why Intel Parallel Studio got high marks during beta. >> http://p.sf.net/sfu/intel-sw-dev >> _______________________________________________ >> amfphp-general mailing list >> amfphp-general@... >> https://lists.sourceforge.net/lists/listinfo/amfphp-general >> > > > ------------------------------------------------------------------------------ > Download Intel® Parallel Studio Eval > Try the new software tools for yourself. Speed compiling, find bugs > proactively, and fine-tune applications for parallel performance. > See why Intel Parallel Studio got high marks during beta. > http://p.sf.net/sfu/intel-sw-dev > _______________________________________________ > amfphp-general mailing list > amfphp-general@... > https://lists.sourceforge.net/lists/listinfo/amfphp-general > ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev _______________________________________________ amfphp-general mailing list amfphp-general@... https://lists.sourceforge.net/lists/listinfo/amfphp-general |
|
|
Re: Class Mapping with 1.9Hi Jacob,
A comment on Wade's blog suggests that ArrayObjects are also automatically converted to ArrayCollections so this might be worth a try: $this_person = new Person(); $this_person->name = 'someName'; $child_array = array(); $child_array[] = new Person(); $child_array[] = new Person(); $this_person->children = new ArrayObject($child_array); See: http://wadearnold.com/blog/flash/amfphp/amfphp-arraycollection#comment-530 Cheers, Darren. On 2/03/2010 4:11 PM, Jacob Steinberger wrote: > ArrayCollection was the easy part, to be honest. I have two > applications, both contain the same code, on contains a lot of other > crap. In the "minimal" program, everything works. In the "full blown" > program the ArrayCollections come through, but the Person does not (in > effect, I end up with a bunch of Objects with ArrayCollections with > Objects). > > Pulling my hair out over it, but I'm sure it's something stupid somewhere ... > > As far as the RemoteBind for ArrayCollection, > flex.messaging.io.ArrayCollection is correct. > mx.collections.ArrayCollection is how you import ArrayCollection, but > in the definition of ArrayCollection, it has a RemoteBind for the > flex.messaging. Seems counter intuitive to rename things like that, > but, meh! > > Jacob > > Quoting Darren Smith<dazquick@...>: > > >> Hi Jacob, >> >> I haven't needed to send ArrayCollections myself (Arrays have always >> sufficed) but I think your PHP ArrayCollection has to map exactly to the >> Flex version, in particular the 'source' property of an ArrayCollection >> object should be set to an Array. Maybe try this: >> >> php, services/vo/mx/collections: >> class ArrayCollection { >> var $source; >> var $_explicitType = "mx.collections.ArrayCollection"; >> } >> >> And create your 'children' ArrayCollection with: >> >> var $child_array = array(); >> $child_array[] = new Person(); >> $child_array[] = new Person(); >> var $children = new ArrayCollection(); >> $children->source = $child_array; >> >> It will probably be something like this although I noticed that in the >> thread I linked to earlier the '_explicitType' is set to >> 'flex.messaging.io.ArrayCollection' and the author claims that this >> works for him. >> >> http://old.nabble.com/Coercion-failed-ArrayCollection-with-Objects-inside-Object-AMFPHP-1.9-to9594166.html >> >> Good luck, >> Darren. >> >> On 2/03/2010 3:04 AM, Jacob Steinberger wrote: >> >>> Flex Builder doesn't like setting event.result to anything other than >>> an Object. I assume that's expected. I buried the Person into >>> event.result.data, and it cam through as a vo.Person without any >>> problems. >>> >>> It doesn't like my ArrayCollection, but it's progress! >>> >>> Thanks for the help Darren, >>> >>> Jacob >>> >>> Quoting Jacob Steinberger<trefalgar@...>: >>> >>> >>> >>>> I'll try the simple path, but I appear to have skipped something in my >>>> last post. With your previous suggestions, I got the output of the >>>> first 'Person' working in PHP, then I went forward with adding the >>>> ArrayCollection. That's when I posted the results. The current PHP >>>> looks like ... >>>> >>>> $array = new Person('one', new ArrayCollection(array(new >>>> Person('two'), new Person('three')))); >>>> >>>> ... which hopefully looks better than my previous PHP snippet. >>>> >>>> Again, I'll try the simple path with just sending a Person with no >>>> ArrayCollection and see if that works. >>>> >>>> Jacob >>>> >>>> Quoting Darren Smith<dazquick@...>: >>>> >>>> >>>> >>>>> Hi Jacob, >>>>> >>>>> Personally to simplify things I would initially send back a simplified >>>>> Person object with no 'children' property (ie. remove the >>>>> property from the >>>>> class in both AS and PHP) to see if the mapping is working correctly. The >>>>> reason is that PHP does not have an ArrayCollection type so having this as >>>>> the type of 'children' on the AS side may be confusing the >>>>> mapping. Get this >>>>> working first and then move on to the ArrayCollection problem. You could >>>>> tell if the mapping is working on this simplified Person object >>>>> as this code >>>>> will throw an error if it's not: >>>>> >>>>> public function result(data:Object):void { >>>>> var thisPerson:Person = data.result; >>>>> } >>>>> >>>>> For the ArrayCollection problem, you can either make the 'children' object >>>>> of type Array on both the AS and PHP sides or create a custom >>>>> ArrayCollection type on the PHP side. Here's an example of this: >>>>> >>>>> http://old.nabble.com/Coercion-failed-ArrayCollection-with-Objects-inside-Ob >>>>> ject-AMFPHP-1.9-to9594166.html >>>>> >>>>> Some more info on AMFPHP and ArrayCollections here: >>>>> >>>>> http://wadearnold.com/blog/flash/amfphp/amfphp-arraycollection >>>>> >>>>> Lastly, this part of your code looks a bit weird: >>>>> >>>>> $array->children = new Person(); >>>>> $array->children->name[] = 'two'; >>>>> $array->children->name[] = 'three'; >>>>> >>>>> 'children' is defined as an ArrayCollection in your AS class but you've >>>>> assigned a Person object to it here. Also, 'name' is a string but you're >>>>> treating like an Array. >>>>> >>>>> I hope this helps. My advice is to start with the simplest >>>>> example and then >>>>> work from there. >>>>> >>>>> Cheers, >>>>> Darren. >>>>> >>>>> On 27/2/10 6:35 AM, "Jacob >>>>> Steinberger"<trefalgar@...> wrote: >>>>> >>>>> >>>>> >>>>>> First, apologies for breaking threading. I don't have the email I want >>>>>> to reply to, available to reply to =\ >>>>>> >>>>>> Darren, thanks for your comments. My output from PHP now looks like thus: >>>>>> >>>>>> Person Object >>>>>> ( >>>>>> [name] => one >>>>>> [children] => ArrayCollection Object >>>>>> ( >>>>>> [_explicitType] => mx.collections.ArrayCollection >>>>>> [source] => Array >>>>>> ( >>>>>> [0] => Person Object >>>>>> ( >>>>>> [name] => two >>>>>> [children] => >>>>>> [_explicitType] => Person >>>>>> ) >>>>>> >>>>>> [1] => Person Object >>>>>> ( >>>>>> [name] => three >>>>>> [children] => >>>>>> [_explicitType] => Person >>>>>> ) >>>>>> >>>>>> ) >>>>>> >>>>>> ) >>>>>> >>>>>> [_explicitType] => Person >>>>>> ) >>>>>> >>>>>> It looks pretty good. But when I view it during a debug session within >>>>>> Flex Builder, it shows up as stock arrays or objects (not as the VO). >>>>>> Is this the expected result? What test can be done on the data inside >>>>>> Flex to show that it was converted to Flex's VOs? >>>>>> >>>>>> I'm familiar with Charles, Wireshark, etc, and the data appears good >>>>>> there. But again, when the data gets to Flex, it doesn't seem right. >>>>>> >>>>>> Jacob >>>>>> >>>>>> Quoting trefalgar@...: >>>>>> >>>>>> >>>>>> >>>>>>> I've searched the internet, read at least a dozen blogs and >>>>>>> tried a ton of >>>>>>> variations of code to get class mapping to work. None of it >>>>>>> does. It seems >>>>>>> the vast majority of examples on the internet are code snippets, >>>>>>> pieces and >>>>>>> fragments - all with comments asking for a full code block because the >>>>>>> examples aren't complete. >>>>>>> >>>>>>> I hope this list is the proper place to ask this kind of question as I'm >>>>>>> at my wits end. I'd like to get this working and post a full >>>>>>> example to the >>>>>>> internet (even if I don't get indexed) just to have a place to >>>>>>> point other >>>>>>> people to that are having the same problem. >>>>>>> >>>>>>> php, services/vo: >>>>>>> class Person { >>>>>>> public $name; >>>>>>> public $children; >>>>>>> >>>>>>> var $_explicitType="vo.Person"; >>>>>>> function Person(){ >>>>>>> } >>>>>>> } >>>>>>> >>>>>>> php, services: >>>>>>> function test3() { >>>>>>> $array = new Person(); >>>>>>> $array->name = 'one'; >>>>>>> $array->children = new Person(); >>>>>>> $array->children->name[] = 'two'; >>>>>>> $array->children->name[] = 'three'; >>>>>>> #$array['_explicitType'] = 'vo.Person'; >>>>>>> #registerClassAlias("vo.Person",Person); >>>>>>> return($array); >>>>>>> } >>>>>>> >>>>>>> Person.as: >>>>>>> package vo { >>>>>>> import mx.collections.ArrayCollection; >>>>>>> [Bindable][RemoteClass(alias="vo.Person")] >>>>>>> public class Person{ >>>>>>> >>>>>>> public var name:String; >>>>>>> public var children:ArrayCollection; >>>>>>> >>>>>>> public function Person(_name:String, >>>>>>> _children:ArrayCollection = >>>>>>> null){ >>>>>>> this.name = _name; >>>>>>> if(_children != null) >>>>>>> this.children = _children; >>>>>>> }//end Person constructor >>>>>>> >>>>>>> }//end Person class >>>>>>> >>>>>>> }//end package declaration >>>>>>> >>>>>>> I've tried every combination of _explicitType, registerClassAlias, and >>>>>>> RemoteClass I've read about. Some sources say you need one, some say you >>>>>>> need two, one even said you need all three. >>>>>>> >>>>>>> I'd appreciate any recommendation or pointing me to a working >>>>>>> example that >>>>>>> I could look at to see how it works for *someone*. >>>>>>> >>>>>>> Jacob >>>>>>> >>>>>>> >>>>>>> >>>>>> >>>>>> >>>>>> ------------------------------------------------------------------------------ >>>>>> Download Intel® Parallel Studio Eval >>>>>> Try the new software tools for yourself. Speed compiling, find bugs >>>>>> proactively, and fine-tune applications for parallel performance. >>>>>> See why Intel Parallel Studio got high marks during beta. >>>>>> http://p.sf.net/sfu/intel-sw-dev >>>>>> _______________________________________________ >>>>>> amfphp-general mailing list >>>>>> amfphp-general@... >>>>>> https://lists.sourceforge.net/lists/listinfo/amfphp-general >>>>>> >>>>>> >>>>> >>>>> ------------------------------------------------------------------------------ >>>>> Download Intel® Parallel Studio Eval >>>>> Try the new software tools for yourself. Speed compiling, find bugs >>>>> proactively, and fine-tune applications for parallel performance. >>>>> See why Intel Parallel Studio got high marks during beta. >>>>> http://p.sf.net/sfu/intel-sw-dev >>>>> _______________________________________________ >>>>> amfphp-general mailing list >>>>> amfphp-general@... >>>>> https://lists.sourceforge.net/lists/listinfo/amfphp-general >>>>> >>>>> >>>>> >>>> >>>> >>>> ------------------------------------------------------------------------------ >>>> Download Intel® Parallel Studio Eval >>>> Try the new software tools for yourself. Speed compiling, find bugs >>>> proactively, and fine-tune applications for parallel performance. >>>> See why Intel Parallel Studio got high marks during beta. >>>> http://p.sf.net/sfu/intel-sw-dev >>>> _______________________________________________ >>>> amfphp-general mailing list >>>> amfphp-general@... >>>> https://lists.sourceforge.net/lists/listinfo/amfphp-general >>>> >>>> >>>> >>> >>> >>> ------------------------------------------------------------------------------ >>> Download Intel® Parallel Studio Eval >>> Try the new software tools for yourself. Speed compiling, find bugs >>> proactively, and fine-tune applications for parallel performance. >>> See why Intel Parallel Studio got high marks during beta. >>> http://p.sf.net/sfu/intel-sw-dev >>> _______________________________________________ >>> amfphp-general mailing list >>> amfphp-general@... >>> https://lists.sourceforge.net/lists/listinfo/amfphp-general >>> >>> >> >> ------------------------------------------------------------------------------ >> Download Intel® Parallel Studio Eval >> Try the new software tools for yourself. Speed compiling, find bugs >> proactively, and fine-tune applications for parallel performance. >> See why Intel Parallel Studio got high marks during beta. >> http://p.sf.net/sfu/intel-sw-dev >> _______________________________________________ >> amfphp-general mailing list >> amfphp-general@... >> https://lists.sourceforge.net/lists/listinfo/amfphp-general >> >> > > > > ------------------------------------------------------------------------------ > Download Intel® Parallel Studio Eval > Try the new software tools for yourself. Speed compiling, find bugs > proactively, and fine-tune applications for parallel performance. > See why Intel Parallel Studio got high marks during beta. > http://p.sf.net/sfu/intel-sw-dev > _______________________________________________ > amfphp-general mailing list > amfphp-general@... > https://lists.sourceforge.net/lists/listinfo/amfphp-general > ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev _______________________________________________ amfphp-general mailing list amfphp-general@... https://lists.sourceforge.net/lists/listinfo/amfphp-general |
|
|
Re: Class Mapping with 1.9Make sure that your VO classes are available before generating the ArrayCollection. MAke sure your VO class in Flex is available before loading the data (you need to reference the Person class somewhere in your app so that the compiler will include it in the swf).
Maybe this will help? http://www.visible-form.com/blog/flex-amfphp-mapping-value-objects/ On Tue, Mar 2, 2010 at 1:14 AM, Darren Smith <dazquick@...> wrote: Hi Jacob, ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev _______________________________________________ amfphp-general mailing list amfphp-general@... https://lists.sourceforge.net/lists/listinfo/amfphp-general |
|
|
Re: Class Mapping with 1.9In the end, ArrayCollections were the easy bit - they're working
without a problem. The issue was the 'Person' vo, the same code in two applications - one conversion works, the other doesn't. The biggest problem I see is there's no debugging on the Flex side as to why a VO *isn't* being converted. Obviously this isn't a problem with amfphp, but it is a problem with Flex. Jacob Quoting Rich Rodecker <flashape2@...>: > Make sure that your VO classes are available before generating the > ArrayCollection. MAke sure your VO class in Flex is available before > loading the data (you need to reference the Person class somewhere in your > app so that the compiler will include it in the swf). > > Maybe this will help? > http://www.visible-form.com/blog/flex-amfphp-mapping-value-objects/ > > > > On Tue, Mar 2, 2010 at 1:14 AM, Darren Smith <dazquick@...> wrote: > >> Hi Jacob, >> >> A comment on Wade's blog suggests that ArrayObjects are also >> automatically converted to ArrayCollections so this might be worth a try: >> >> $this_person = new Person(); >> $this_person->name = 'someName'; >> $child_array = array(); >> $child_array[] = new Person(); >> $child_array[] = new Person(); >> $this_person->children = new ArrayObject($child_array); >> >> See: >> http://wadearnold.com/blog/flash/amfphp/amfphp-arraycollection#comment-530 >> >> Cheers, >> Darren. >> >> On 2/03/2010 4:11 PM, Jacob Steinberger wrote: >> > ArrayCollection was the easy part, to be honest. I have two >> > applications, both contain the same code, on contains a lot of other >> > crap. In the "minimal" program, everything works. In the "full blown" >> > program the ArrayCollections come through, but the Person does not (in >> > effect, I end up with a bunch of Objects with ArrayCollections with >> > Objects). >> > >> > Pulling my hair out over it, but I'm sure it's something stupid somewhere >> ... >> > >> > As far as the RemoteBind for ArrayCollection, >> > flex.messaging.io.ArrayCollection is correct. >> > mx.collections.ArrayCollection is how you import ArrayCollection, but >> > in the definition of ArrayCollection, it has a RemoteBind for the >> > flex.messaging. Seems counter intuitive to rename things like that, >> > but, meh! >> > >> > Jacob >> > >> > Quoting Darren Smith<dazquick@...>: >> > >> > >> >> Hi Jacob, >> >> >> >> I haven't needed to send ArrayCollections myself (Arrays have always >> >> sufficed) but I think your PHP ArrayCollection has to map exactly to the >> >> Flex version, in particular the 'source' property of an ArrayCollection >> >> object should be set to an Array. Maybe try this: >> >> >> >> php, services/vo/mx/collections: >> >> class ArrayCollection { >> >> var $source; >> >> var $_explicitType = "mx.collections.ArrayCollection"; >> >> } >> >> >> >> And create your 'children' ArrayCollection with: >> >> >> >> var $child_array = array(); >> >> $child_array[] = new Person(); >> >> $child_array[] = new Person(); >> >> var $children = new ArrayCollection(); >> >> $children->source = $child_array; >> >> >> >> It will probably be something like this although I noticed that in the >> >> thread I linked to earlier the '_explicitType' is set to >> >> 'flex.messaging.io.ArrayCollection' and the author claims that this >> >> works for him. >> >> >> >> >> http://old.nabble.com/Coercion-failed-ArrayCollection-with-Objects-inside-Object-AMFPHP-1.9-to9594166.html >> >> >> >> Good luck, >> >> Darren. >> >> >> >> On 2/03/2010 3:04 AM, Jacob Steinberger wrote: >> >> >> >>> Flex Builder doesn't like setting event.result to anything other than >> >>> an Object. I assume that's expected. I buried the Person into >> >>> event.result.data, and it cam through as a vo.Person without any >> >>> problems. >> >>> >> >>> It doesn't like my ArrayCollection, but it's progress! >> >>> >> >>> Thanks for the help Darren, >> >>> >> >>> Jacob >> >>> >> >>> Quoting Jacob Steinberger<trefalgar@...>: >> >>> >> >>> >> >>> >> >>>> I'll try the simple path, but I appear to have skipped something in my >> >>>> last post. With your previous suggestions, I got the output of the >> >>>> first 'Person' working in PHP, then I went forward with adding the >> >>>> ArrayCollection. That's when I posted the results. The current PHP >> >>>> looks like ... >> >>>> >> >>>> $array = new Person('one', new ArrayCollection(array(new >> >>>> Person('two'), new Person('three')))); >> >>>> >> >>>> ... which hopefully looks better than my previous PHP snippet. >> >>>> >> >>>> Again, I'll try the simple path with just sending a Person with no >> >>>> ArrayCollection and see if that works. >> >>>> >> >>>> Jacob >> >>>> >> >>>> Quoting Darren Smith<dazquick@...>: >> >>>> >> >>>> >> >>>> >> >>>>> Hi Jacob, >> >>>>> >> >>>>> Personally to simplify things I would initially send back a >> simplified >> >>>>> Person object with no 'children' property (ie. remove the >> >>>>> property from the >> >>>>> class in both AS and PHP) to see if the mapping is working correctly. >> The >> >>>>> reason is that PHP does not have an ArrayCollection type so having >> this as >> >>>>> the type of 'children' on the AS side may be confusing the >> >>>>> mapping. Get this >> >>>>> working first and then move on to the ArrayCollection problem. You >> could >> >>>>> tell if the mapping is working on this simplified Person object >> >>>>> as this code >> >>>>> will throw an error if it's not: >> >>>>> >> >>>>> public function result(data:Object):void { >> >>>>> var thisPerson:Person = data.result; >> >>>>> } >> >>>>> >> >>>>> For the ArrayCollection problem, you can either make the 'children' >> object >> >>>>> of type Array on both the AS and PHP sides or create a custom >> >>>>> ArrayCollection type on the PHP side. Here's an example of this: >> >>>>> >> >>>>> >> http://old.nabble.com/Coercion-failed-ArrayCollection-with-Objects-inside-Ob >> >>>>> ject-AMFPHP-1.9-to9594166.html >> >>>>> >> >>>>> Some more info on AMFPHP and ArrayCollections here: >> >>>>> >> >>>>> http://wadearnold.com/blog/flash/amfphp/amfphp-arraycollection >> >>>>> >> >>>>> Lastly, this part of your code looks a bit weird: >> >>>>> >> >>>>> $array->children = new Person(); >> >>>>> $array->children->name[] = 'two'; >> >>>>> $array->children->name[] = 'three'; >> >>>>> >> >>>>> 'children' is defined as an ArrayCollection in your AS class but >> you've >> >>>>> assigned a Person object to it here. Also, 'name' is a string but >> you're >> >>>>> treating like an Array. >> >>>>> >> >>>>> I hope this helps. My advice is to start with the simplest >> >>>>> example and then >> >>>>> work from there. >> >>>>> >> >>>>> Cheers, >> >>>>> Darren. >> >>>>> >> >>>>> On 27/2/10 6:35 AM, "Jacob >> >>>>> Steinberger"<trefalgar@...> wrote: >> >>>>> >> >>>>> >> >>>>> >> >>>>>> First, apologies for breaking threading. I don't have the email I >> want >> >>>>>> to reply to, available to reply to =\ >> >>>>>> >> >>>>>> Darren, thanks for your comments. My output from PHP now looks like >> thus: >> >>>>>> >> >>>>>> Person Object >> >>>>>> ( >> >>>>>> [name] => one >> >>>>>> [children] => ArrayCollection Object >> >>>>>> ( >> >>>>>> [_explicitType] => mx.collections.ArrayCollection >> >>>>>> [source] => Array >> >>>>>> ( >> >>>>>> [0] => Person Object >> >>>>>> ( >> >>>>>> [name] => two >> >>>>>> [children] => >> >>>>>> [_explicitType] => Person >> >>>>>> ) >> >>>>>> >> >>>>>> [1] => Person Object >> >>>>>> ( >> >>>>>> [name] => three >> >>>>>> [children] => >> >>>>>> [_explicitType] => Person >> >>>>>> ) >> >>>>>> >> >>>>>> ) >> >>>>>> >> >>>>>> ) >> >>>>>> >> >>>>>> [_explicitType] => Person >> >>>>>> ) >> >>>>>> >> >>>>>> It looks pretty good. But when I view it during a debug session >> within >> >>>>>> Flex Builder, it shows up as stock arrays or objects (not as the >> VO). >> >>>>>> Is this the expected result? What test can be done on the data >> inside >> >>>>>> Flex to show that it was converted to Flex's VOs? >> >>>>>> >> >>>>>> I'm familiar with Charles, Wireshark, etc, and the data appears good >> >>>>>> there. But again, when the data gets to Flex, it doesn't seem right. >> >>>>>> >> >>>>>> Jacob >> >>>>>> >> >>>>>> Quoting trefalgar@...: >> >>>>>> >> >>>>>> >> >>>>>> >> >>>>>>> I've searched the internet, read at least a dozen blogs and >> >>>>>>> tried a ton of >> >>>>>>> variations of code to get class mapping to work. None of it >> >>>>>>> does. It seems >> >>>>>>> the vast majority of examples on the internet are code snippets, >> >>>>>>> pieces and >> >>>>>>> fragments - all with comments asking for a full code block because >> the >> >>>>>>> examples aren't complete. >> >>>>>>> >> >>>>>>> I hope this list is the proper place to ask this kind of question >> as I'm >> >>>>>>> at my wits end. I'd like to get this working and post a full >> >>>>>>> example to the >> >>>>>>> internet (even if I don't get indexed) just to have a place to >> >>>>>>> point other >> >>>>>>> people to that are having the same problem. >> >>>>>>> >> >>>>>>> php, services/vo: >> >>>>>>> class Person { >> >>>>>>> public $name; >> >>>>>>> public $children; >> >>>>>>> >> >>>>>>> var $_explicitType="vo.Person"; >> >>>>>>> function Person(){ >> >>>>>>> } >> >>>>>>> } >> >>>>>>> >> >>>>>>> php, services: >> >>>>>>> function test3() { >> >>>>>>> $array = new Person(); >> >>>>>>> $array->name = 'one'; >> >>>>>>> $array->children = new Person(); >> >>>>>>> $array->children->name[] = 'two'; >> >>>>>>> $array->children->name[] = 'three'; >> >>>>>>> #$array['_explicitType'] = 'vo.Person'; >> >>>>>>> #registerClassAlias("vo.Person",Person); >> >>>>>>> return($array); >> >>>>>>> } >> >>>>>>> >> >>>>>>> Person.as: >> >>>>>>> package vo { >> >>>>>>> import mx.collections.ArrayCollection; >> >>>>>>> [Bindable][RemoteClass(alias="vo.Person")] >> >>>>>>> public class Person{ >> >>>>>>> >> >>>>>>> public var name:String; >> >>>>>>> public var children:ArrayCollection; >> >>>>>>> >> >>>>>>> public function Person(_name:String, >> >>>>>>> _children:ArrayCollection = >> >>>>>>> null){ >> >>>>>>> this.name = _name; >> >>>>>>> if(_children != null) >> >>>>>>> this.children = _children; >> >>>>>>> }//end Person constructor >> >>>>>>> >> >>>>>>> }//end Person class >> >>>>>>> >> >>>>>>> }//end package declaration >> >>>>>>> >> >>>>>>> I've tried every combination of _explicitType, registerClassAlias, >> and >> >>>>>>> RemoteClass I've read about. Some sources say you need one, some >> say you >> >>>>>>> need two, one even said you need all three. >> >>>>>>> >> >>>>>>> I'd appreciate any recommendation or pointing me to a working >> >>>>>>> example that >> >>>>>>> I could look at to see how it works for *someone*. >> >>>>>>> >> >>>>>>> Jacob ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev _______________________________________________ amfphp-general mailing list amfphp-general@... https://lists.sourceforge.net/lists/listinfo/amfphp-general |
| Free embeddable forum powered by Nabble | Forum Help |