Aha! I had obviously missed the bit about the "new User()" when I was trying
to adapt the example code.

Sadly, today my flex2gateway has started throwing a 500 error again for no
apparent reason so I can't test it until I figure out how to fix that. I
really hate how flaky this thing is - apparently just turning your computer
off for the night is enough to take it out even if you make no other
changes. :(


As for the CFC side of things, yes, the CFC does return a query object
directly. I'd not realised that there was any other way to go about this.
Like the idea of actually returning it as a User object, though. Once I get
the flex2gateway issue sorted I'll have a play with this too. Thanks for the
tip. :)

Cheers,

Seona.

2009/5/4 Tom McNeer <[email protected]>

>   The first thing I see is that you have not declared thisUser as a new
> User. In your initial code, either do:
> public var thisUser:User = new User();
>
> ...or in your function, do:
> thisUser:User = new User();
>
> ... then follow with your thisUser.id code.
>
> Another suggestion, though. On the Flex side, you have a User class created
> to use as a VO:
>
>>
>> [Bindable]
>>     public class User
>>
>
> ... but the result of your service call is expecting an ArrayCollection:
>         public function login(userDetail:ArrayCollection):Boolean {
>
>             if (userDetail.length > 0) {
>                thisUser.id = userDetail.getItemAt(0).id as Number;
>                return true;
>             }
>             return false;
>         }
>
> Is UserDetail really an ArrayCollection? What's happening in your CFC
> method? It appears as if you're passing a <cfquery> object, so I'm guessing
> you're doing a query based on the login information, and returning the query
> object directly.
>
> While that will work, you should think about having a matching User object
> the CF side. The signature needs to be the same as that of User.as, and
> User.as will need an "alias" statement at the top which refers to the CFC
> dot-delimited path. Check the CF docs about this. Fill the User.cfc with the
> data from your query, send the User object to Flex, and it will
> automatically be converted into an object of the User class. No
> ArrayCollection stuff.
>
> Alternatively, from your query, you can create a "typed struct," which
> "pretends" to be a User.cfc. Like this:
>
> <cfset userStruct = structNew() />
>
> <cfset userStruct['__type__'] = "path.to.User" /> (Note the two underscores
> on either side of 'type.')
>
> <cfset userStruct['id'] = myQuery.id />
>
> ... and so on. Return the struct to Flex, and it will be typed as a User
> VO, populated from CF.
>

Reply via email to