The light bulb just went on! Thanks for pointing me in the right direction!
 
Shan


From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Peter Farland
Sent: Thursday, July 06, 2006 10:18 AM
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders] arrayCollection to custom value object

This is controlled by CFQuery, so you’d either have to change the data format in CF before you return it, or continue to do what you’re doing on the client by copying each property across (although I’d use a for/in loop and [propName]-styled syntax against the currentUser type rather than specifically writing a line to copy each item). You can’t cast an Object into another type unless it is literally of that type to begin with… as is the case with any strongly typed language.


From: flexcoders@yahoogroups.com [mailto:flexcoders@yahoogroups.com] On Behalf Of Shannon Hicks
Sent: Thursday, July 06, 2006 11:03 AM
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders] arrayCollection to custom value object

The ArrayCollection was returned from a CFC (just a simple select * query).

Shan


From: flexcoders@yahoogroups.com [mailto:flexcoders@yahoogroups.com] On Behalf Of Peter Farland
Sent: Thursday, July 06, 2006 9:23 AM
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders] arrayCollection to custom value object

I don’t have enough information here to determine how you got an ArrayCollection in the first place?


From: flexcoders@yahoogroups.com [mailto:flexcoders@yahoogroups.com] On Behalf Of Shannon Hicks
Sent: Wednesday, July 05, 2006 11:34 PM
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders] arrayCollection to custom value object

So, how can I get my ArrayCollection row into my object? It's cool that I can test and see that it's not working using "IS", but it doesn't solve the problem, just allows me to trap it :)

Shan


From: flexcoders@yahoogroups.com [mailto:flexcoders@yahoogroups.com] On Behalf Of Peter Farland
Sent: Wednesday, July 05, 2006 10:07 PM
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders] arrayCollection to custom value object

The item may not be an instance of user, but rather an anonymous Object that contains the correct properties that match the public interface of the user class. The “as” operator returns null if the instance cannot be coerced into the requested type… where as traditional casting syntax will throw an error. You can use getQualifiedClassName or the “is” operator to determine whether an instance is of a particular type before casting or using the as operator.


From: flexcoders@yahoogroups.com [mailto:flexcoders@yahoogroups.com] On Behalf Of Shannon Hicks
Sent: Wednesday, July 05, 2006 9:40 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] arrayCollection to custom value object

So, I've got an ArrayCollection and a defined value object. The ArrayCollection has just one record in it, and the data matches the valueObject perfectly. Here's my code:

If I do this, everything works:

      model.currentUser.userID = loginResult.getItemAt(0).userID;
      model.currentUser.username = loginResult.getItemAt(0).username;
      model.currentUser.name = loginResult.getItemAt(0).name;
      model.currentUser.email = loginResult.getItemAt(0).email;
      model.currentUser.city = loginResult.getItemAt(0).city;
      model.currentUser.state = loginResult.getItemAt(0).state;
      model.currentUser.country = loginResult.getItemAt(0).country;
      model.currentUser.approved = loginResult.getItemAt(0).approved;
      model.currentUser.lastLogin = loginResult.getItemAt(0).lastLogin;
      model.currentUser.createDate = loginResult.getItemAt(0).createDate;

If I do EITHER OF THESE (not all at once), model.currentUser remains NULL:

1    model.currentUser = loginResult.getItemAt(0) as user;
2    model.currentUser = loginResult as user;

Any ideas what I'm doing wrong?

Shan

--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.394 / Virus Database: 268.9.9/382 - Release Date: 7/4/2006

--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.394 / Virus Database: 268.9.9/382 - Release Date: 7/4/2006

--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.394 / Virus Database: 268.9.9/382 - Release Date: 7/4/2006

--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.394 / Virus Database: 268.9.9/382 - Release Date: 7/4/2006

--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.394 / Virus Database: 268.9.9/382 - Release Date: 7/4/2006


--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.394 / Virus Database: 268.9.9/382 - Release Date: 7/4/2006

__._,_.___

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com





SPONSORED LINKS
Web site design development Computer software development Software design and development
Macromedia flex Software development best practice


YAHOO! GROUPS LINKS




__,_._,___

--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.394 / Virus Database: 268.9.9/382 - Release Date: 7/4/2006

Reply via email to