Deserialization of Zend_Db_Table_Rowset Objects in Flex 3

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Deserialization of Zend_Db_Table_Rowset Objects in Flex 3

Miggl
Hi Everyone,

First of all, I would like to appologize if cross-posting in different lists is frowned upon (I thought it would be a good idea, since they seem both equally applicable).

My situtation is this:

I have a Users class, that is derived from Zend_Db_Table_Abstract, which refers to my User class for the rowsets, which is implemented via Zend_Db_Table_Rowset_Abstract. Everything works dandy within Zend Framework.
However, when I use Zend_Amf to communicate with FLEX 3, and bind the result to a datagrid, it is unable to de-serialize the object passed in, and can only recognize it as a User object. I'm haven't been able to find any tutorials on passing Zend_Db_* objects between FLEX and ZF anywhere, so I'm not completely sure how to structure the mirroring class in ActionScript on the Flex side, or even handle the request result.

Can anyone shed any light on this?

Thanks very much!
-Mike
Reply | Threaded
Open this post in threaded view
|

Re: Deserialization of Zend_Db_Table_Rowset Objects in Flex 3

weierophinney
Administrator
-- Mike Bronner <[hidden email]> wrote
(on Thursday, 22 January 2009, 04:30 PM -0800):

> First of all, I would like to appologize if cross-posting in different lists is
> frowned upon (I thought it would be a good idea, since they seem both equally
> applicable).
>
> My situtation is this:
>
> I have a Users class, that is derived from Zend_Db_Table_Abstract, which refers
> to my User class for the rowsets, which is implemented via
> Zend_Db_Table_Rowset_Abstract. Everything works dandy within Zend Framework.
> However, when I use Zend_Amf to communicate with FLEX 3, and bind the result to
> a datagrid, it is unable to de-serialize the object passed in, and can only
> recognize it as a User object. I'm haven't been able to find any tutorials on
> passing Zend_Db_* objects between FLEX and ZF anywhere, so I'm not completely
> sure how to structure the mirroring class in ActionScript on the Flex side, or
> even handle the request result.
>
> Can anyone shed any light on this?

Instead of returning the rowset object directly, return the value of
toArray():

    return $rowset->toArray();

This will return a struct that should be easily serializable by
Zend_Amf.

--
Matthew Weier O'Phinney
Software Architect       | [hidden email]
Zend Framework           | http://framework.zend.com/
Reply | Threaded
Open this post in threaded view
|

Re: Deserialization of Zend_Db_Table_Rowset Objects in Flex 3

Miggl
This indeed seems to work, thanks!

The problem I have now is that Zend_Amf is not sending this "across the wire" as an object of type user, but rather as a plain array (I'm using charles to inspect the communication traffic). Unfortunately due to that, it appears that Flex complains when trying to cast the resultset as an ActiveScript user.

Thoughts?

Thanks!
Mike

On Fri, Jan 23, 2009 at 9:32 AM, Matthew Weier O'Phinney <[hidden email]> wrote:
-- Mike Bronner <[hidden email]> wrote
(on Thursday, 22 January 2009, 04:30 PM -0800):
> First of all, I would like to appologize if cross-posting in different lists is
> frowned upon (I thought it would be a good idea, since they seem both equally
> applicable).
>
> My situtation is this:
>
> I have a Users class, that is derived from Zend_Db_Table_Abstract, which refers
> to my User class for the rowsets, which is implemented via
> Zend_Db_Table_Rowset_Abstract. Everything works dandy within Zend Framework.
> However, when I use Zend_Amf to communicate with FLEX 3, and bind the result to
> a datagrid, it is unable to de-serialize the object passed in, and can only
> recognize it as a User object. I'm haven't been able to find any tutorials on
> passing Zend_Db_* objects between FLEX and ZF anywhere, so I'm not completely
> sure how to structure the mirroring class in ActionScript on the Flex side, or
> even handle the request result.
>
> Can anyone shed any light on this?

Instead of returning the rowset object directly, return the value of
toArray():

   return $rowset->toArray();

This will return a struct that should be easily serializable by
Zend_Amf.

--
Matthew Weier O'Phinney
Software Architect       | [hidden email]
Zend Framework           | http://framework.zend.com/



--
Celebrate Liberty, Freedom, and Rights at http://www.theconstitutionalist.us.