[flexcoders] Re: Convert Object to a Value Object

2006-11-03 Thread mvbaffa
Hi all,

Thanks for your help. I was out for a few days, but today I will 
try, using your advises, to solve the problem.

Thank you very much

--- In flexcoders@yahoogroups.com, Darron J. Schall [EMAIL PROTECTED] 
wrote:

 Interesting, Yahoo garbled most of the content of that message.  
Here's 
 what I actually sent:
 
 For those having trouble converting generic objects into class 
instances 
 (Value Objects), I've created an ObjectTranslator.objectToInstance 
 method to take care of the problem: 
 http://www.darronschall.com/weblog/archives/000247.cfm
 
 Essentially, it allows you to convert any plain old object into a 
class
 instance.  Usage is as follows:
 
 import com.darronschall.examples.vo.Book;
 import com.darronschall.serialization.ObjectTranslator;
 
 // Define an object with properties that mimic the variable names
 // inside of the Book class
 var bookObj:Object = { title: My Book title, pageCount: 10, 
inLibrary: true };
 
 // Convert the generic object into an instance of the Book class
 var book:Book = ObjectTranslator.objectToInstance( bookObj, Book ) 
as Book;
 
 
 Originally it was written so that JSON behaved more like 
RemoteObject 
 (returning class instances from the server instead of just plain 
 objects), but the method is generic enough to be useful in a lot 
of 
 situations.
 
 Hope that helps...
 
 -d
 
 Darron J. Schall wrote:
 
  Originally it was written so that JSON behaved more like 
RemoteObject 
  (returning class instances from the server instead of just plain 
  objects), but the method is generic enough to be useful in a lot 
of 
  situations.
 
  Hope that helps...
 
  -d
 
  mvbaffa wrote:
 
 
  - Type Coercion failed: cannot convert [EMAIL PROTECTED] to
  com.mvb.boe.vo.UserAccountVO.
 
 
 






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

* To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/

* Your email settings:
Individual Email | Traditional

* To change settings online go to:
http://groups.yahoo.com/group/flexcoders/join
(Yahoo! ID required)

* To change settings via email:
mailto:[EMAIL PROTECTED] 
mailto:[EMAIL PROTECTED]

* To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]

* Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
 



[flexcoders] Re: Convert Object to a Value Object

2006-10-29 Thread Michael Labriola

nicely done

--- In flexcoders@yahoogroups.com, Darron J. Schall [EMAIL PROTECTED] wrote:

 Interesting, Yahoo garbled most of the content of that message.  Here's 
 what I actually sent:
 
 For those having trouble converting generic objects into class
instances 
 (Value Objects), I've created an ObjectTranslator.objectToInstance 
 method to take care of the problem: 
 http://www.darronschall.com/weblog/archives/000247.cfm
 
 Essentially, it allows you to convert any plain old object into a class 
 instance.  Usage is as follows:
 
 import com.darronschall.examples.vo.Book;
 import com.darronschall.serialization.ObjectTranslator;
 
 // Define an object with properties that mimic the variable names
 // inside of the Book class
 var bookObj:Object = { title: My Book title, pageCount: 10,
inLibrary: true };
 
 // Convert the generic object into an instance of the Book class
 var book:Book = ObjectTranslator.objectToInstance( bookObj, Book )
as Book;
 
 
 Originally it was written so that JSON behaved more like RemoteObject 
 (returning class instances from the server instead of just plain 
 objects), but the method is generic enough to be useful in a lot of 
 situations.
 
 Hope that helps...
 
 -d
 
 Darron J. Schall wrote:
 
  Originally it was written so that JSON behaved more like RemoteObject 
  (returning class instances from the server instead of just plain 
  objects), but the method is generic enough to be useful in a lot of 
  situations.
 
  Hope that helps...
 
  -d
 
  mvbaffa wrote:
 
 
  - Type Coercion failed: cannot convert [EMAIL PROTECTED] to
  com.mvb.boe.vo.UserAccountVO.
 
 
 






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

* To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/

* Your email settings:
Individual Email | Traditional

* To change settings online go to:
http://groups.yahoo.com/group/flexcoders/join
(Yahoo! ID required)

* To change settings via email:
mailto:[EMAIL PROTECTED] 
mailto:[EMAIL PROTECTED]

* To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]

* Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
 



[flexcoders] Re: Convert Object to a Value Object

2006-10-28 Thread Michael Labriola

2 more things to consider.

Not sure of your particular setup, but, you may want to look at the
[Managed] metadata tag. Setup dependent, it may be what you are
looking for.

Second, and more generally, casts fail when the system cannot convert
one type to another. So, take a look at your objects. You mentioned
setting the params one by one, a common technique is to build a static
method which accepts an Object and returns (by internally assigning
the properties) your value object.

Just a couple of thoughts,
--Mike




--- In flexcoders@yahoogroups.com, Shannon Hicks [EMAIL PROTECTED] wrote:

 Try assigning it via the preferred method:
  
 userAccount = event.result as UserAccountVO;
  
 Shan
 
_  
 
 From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
 Behalf Of mvbaffa
 Sent: Saturday, October 28, 2006 2:36 PM
 To: flexcoders@yahoogroups.com
 Subject: [flexcoders] Convert Object to a Value Object
 
 
 
 Hi All,
 
 This is pretty basic but I cannot find the problem. I have service 
 that returns a userAccountVO. When I receive the result I am trying 
 to convert the event.result, that is an Object, to UserAccountVO and 
 I receive an error:
 
 - Type Coercion failed: cannot convert [EMAIL PROTECTED] to 
 com.mvb.boe.-vo.UserAccountVO-.
 
 Well the code is very simple like this:
 
 var userAccount: UserAccountVO = new UserAccountVO(-);
 userAccount = UserAccountVO(-event.result)-;
 
 In another application I had the same problem but solved it 
 assigning the properties one by one.
 
 What is the problem 
 
 Thanks in advance.
 
 
 
  
 
 
 --
 No virus found in this incoming message.
 Checked by AVG Free Edition.
 Version: 7.1.408 / Virus Database: 268.13.17/505 - Release Date:
10/27/2006
 
 
 
 -- 
 No virus found in this outgoing message.
 Checked by AVG Free Edition.
 Version: 7.1.408 / Virus Database: 268.13.17/505 - Release Date:
10/27/2006






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

* To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/

* Your email settings:
Individual Email | Traditional

* To change settings online go to:
http://groups.yahoo.com/group/flexcoders/join
(Yahoo! ID required)

* To change settings via email:
mailto:[EMAIL PROTECTED] 
mailto:[EMAIL PROTECTED]

* To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]

* Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/