I am using AMFPHP 1.9 which I think uses AMF3.
I think I zero'd in on the problem. If I have my PHP class only send
strings, then the typing works (without any constructor conversion).
However, when I try to map other data types, I get the error.
I modified my UserDataVO to only contain string types, and I was able
to easily map the PHP VO using the $_explicitType variable in PHP and
the [RemoteClass] meta tag in Flex. I am now going to test some
other data types and see which ones throw the Coercion error.
I'll post when I have more info. In the mean time you may want to
look at this other PHP/Flex list which has some good posts:
http://groups.google.com/group/adobe_php_sdk/browse_thread/thread/
ac92eba7eb46632b
The end of this thread explains the problems we are having...without
any solution that I could find yet...
- Kevin
On Feb 10, 2007, at 11:32 AM, Mike Crowe wrote:
Interesting. I'm also using the renaun AMF0 templates. I wonder if
that could be the problem. Have you moved to any AMF3 setups?
--- In [email protected], Kevin <[EMAIL PROTECTED]> wrote:
>
> wow. this seems like a lot of work to just map a VO object. Makes me
> wonder if it is worth it. What's the point of mapping the objects if
> you have to do the conversion manually anyway?
>
> What is weird is that in another command, I have an array of VO's
> being returned from PHP which all map correctly using the
> $_explicitType variable. However, when i simply return only one VO
> object from PHP, then I get the error.
>
> I'll keep looking into this...
>
> Thanks, Kevin
>
>
>
>
> On Feb 10, 2007, at 8:15 AM, Mike Crowe wrote:
>
> > Kevin,
> >
> > I'm in the same boat. I had to initialize my VO object in the
> > constructor. So, in your getUserInfo(), you would do (using my
VO):
> >
> > var teamData:TeamVO = new TeamVO(data.result);
> >
> > and in your VO:
> >
> > public function TeamVO(toSet:Object=null) {
> > registerClassAlias("com.mikecrowe.all.vo.TeamVO", TeamVO);
> > _uuid = UIDUtil.createUID();
> > if ( toSet ) {
> > try { uuid = toSet.uuid; } catch ( e:Error ) {
> > trace("Error setting uuid: "+e); }
> > try { id = toSet.id; } catch ( e:Error ) { trace("Error
> > setting id: "+e); }
> > try { created_by = toSet.created_by; } catch ( e:Error )
> > { trace("Error setting created_by: "+e); }
> > try { created_on = parseDate(toSet.created_on); } catch
> > ( e:Error ) { trace("Error setting created_on: "+e); }
> > try { updated_by = toSet.updated_by; } catch ( e:Error )
> > { trace("Error setting updated_by: "+e); }
> > try { updated_on = parseDate(toSet.updated_on); } catch
> > ( e:Error ) { trace("Error setting updated_on: "+e); }
> > try { parent_id = toSet.parent_id; } catch ( e:Error ) {
> > trace("Error setting parent_id: "+e); }
> > try { contact_id = toSet.contact_id; } catch ( e:Error )
> > { trace("Error setting contact_id: "+e); }
> > try { cat_id = toSet.cat_id; } catch ( e:Error ) {
> > trace("Error setting cat_id: "+e); }
> > try { team_is_global = toSet.team_is_global; } catch (
> > e:Error ) { trace("Error setting team_is_global: "+e); }
> > try { team_organizat_personal =
> > toSet.team_organizat_personal; } catch ( e:Error ) { trace("Error
> > setting team_organizat_personal: "+e); }
> > try { team_abbreviation = toSet.team_abbreviation; }
> > catch ( e:Error ) { trace("Error setting team_abbreviation:
"+e); }
> > try { team_name = toSet.team_name; } catch ( e:Error ) {
> > trace("Error setting team_name: "+e); }
> > try { team_emails = toSet.team_emails; } catch ( e:Error
> > ) { trace("Error setting team_emails: "+e); }
> > }
> > }
> >
> > Note: The individual try{} statements are important. I had it
around
> > all the assignments before, and it ends up not initializing.
> >
> > Additionally, I'm working on a templating system that creates all
> > the VO
> > objects, PHP objects, and a basic CRUD interface. It's crude
now, but
> > working for me.
> >
> > If you want to chat about it, IM me at mikecrowe (yahoo) or
> > mike(a)mikeandkellycrowe(d)com (msn).
> >
> > Mike
> >
> > --- In [email protected], Kevin <lists@> wrote:
> > >
> > > I am still having some problems using explicitType with PHP &
Flex.
> > > I am trying to send a basic Object back from PHP to flex and
have it
> > > map to a VO. I think I have it all set up correctly, but I
continue
> > > to get an error:
> > >
> > > IN FLEX VO UserDataVO.as
> > >
> > > [RemoteClass("com.onefoot.dbocl.services.vo.users.UserDataVO")]
> > >
> > > IN PHP VO UserDataVO.php
> > > var $_explicitType =
> > "com.onefoot.dbocl.services.vo.users.UserDataVO";
> > >
> > > SEND FROM PHP
> > > public function getUserInfo(){
> > > /* retrieve session variables from server
> > > */
> > > $User = new UserDataVO();
> > > $User->fullName = "Test User";
> > > $User->firstName = "Test";
> > > $User->lastName = "User";
> > >
> > > return $User;
> > > }
> > >
> > >
> > > RECEIVE IN FLEX from getUserInfo() call
> > > public function result(data:Object):void
> > > {
> > > var userData:UserDataVO = data.result;
> > > }
> > >
> > > ERROR
> > > Type Coercion failed: cannot convert
mx.utils::[EMAIL PROTECTED]
> > > to com.onefoot.dbocl.vo.users.UserDataVO.
> > >
> > >
> > >
> > > Thanks for the help!
> > >
> > > - Kevin
> > >
> >
> >
> >
>