I was about to post a question on 'Using Value Objects with CFC' and your example explains it all.
Thanks again. Mohanraj --- "Mehdi, Agha" <[EMAIL PROTECTED]> wrote: > You can also implement mapping like this > > ============================================= > 1. AS VO > ---------- > Class TestVO > { > public var test1 : String; > public var test2 : Array; > > function TestVO () > { > Object.registerClass ( "testVO", TestVO ); > } > } > > testVO = new TestVO(); > remoteObject.passToCF ( testVO ); > ================================================= > > 2. CF > ---------- > <cffunction name="getASObject" returntype="any" > access="remote"> > <cfargument name="testVO" type="struct" > required="yes"> > > <cfset var _asVO = arguments.testVO.getType()> > <cfset var _cfVO = CreateObject( "component", _asVO > )> > > <cfset _cfVO["test1"] = arguments.testVO["test1"]> > <cfset _cfVO["test2"] = arguments.testVO["test2"]> > </cffunction> > > <cffunction name="passASObject" returntype="struct" > access="remote"> > <cfargument name="cfVO" type="TestVO" > required="yes"> > > <cfset var _asVO = CreateObject( "java", > "flashgateway.io.ASObject" > ).init()> > > <cfset _asVO.setType( "testVO" )> > <cfset _asVO["test1"] = arguments.cfVO["test1"]> > <cfset _asVO["test2"] = arguments.cfVO["test2"]> > > <cfreturn _asVO> > > </cffunction> > =========================================================== > > 3. AS receiving the VO from CF > -------------------------------------- > public / private var testVO : TestVO; > testVO = event.result; > ============================================== > > That should get you going. You might wanna make this > mapping a process, > which your service layer invokes before getting Vos > into and out of your > backend. You can make it so that you define > variables of your CF VO as > properties and loop over the properties to auto > populate the AS VO going out > and the same when you read the AS VO. You might also > wanna look into Tartan, > which has this mapping built into it and offers > seemless integration. > > Let me know if you have any questions. > > Thanks > > -----Original Message----- > From: Tom Link [mailto:[EMAIL PROTECTED] > Sent: Monday, March 28, 2005 9:59 PM > To: flexcoders@yahoogroups.com > Subject: RE: [flexcoders] How to pass AS Objects to > a CFC > > > I believe the solution Dirk provided solves this > problem as well. > That is, in addition to Mehdi's initial solution #2: > > > > > remoteObject.cfFunction ( toPass, true ); > > You can use named argument syntax: > remoteObject.cfFunction({arg1:toPass}); > > Where arg1 is also the name of the argument in the > CFC method "cfFunction". > > Mohanraj, this is the solution I posted in my blog: > http://tomlink.net/blog/index.cfm?mode=entry&entry=BBFE84D5-7E97-A3B0-EE0B2D > C292F5272F, where you also posed this question. > Please correct me if I am > missing something. > > -tom > > > -----Original Message----- > > From: Mohanraj Jayaraman > [mailto:[EMAIL PROTECTED] > > Sent: Friday, March 25, 2005 5:44 PM > > To: flexcoders@yahoogroups.com > > Subject: RE: [flexcoders] How to pass AS Objects > to a CFC > > > > > > Thanks for the explantion Peter. That really > helps. > > Mehdi thanks for yet another Tip. > > It works in FLEX. > > > > Mohanraj > > > > > > --- "Mehdi, Agha" <[EMAIL PROTECTED]> wrote: > > > > > Thanks Peter for the explanation. That explains > it. > > > I am glad it worked > > > Mohanraj. > > > > > > There's one more way of doing it without having > to specify the other > > > argument. > > > > > > var testObject = new Array(); // it has to be > an array. It won't > > > work if you did new Object() > > > > > > testObject["var1"] = "var1"; > > > testObject["var2"] = "var2" > > > > > > remoteObject.cfFunction ( testObject ); > > > > > > <cffunction name="cfFunction" access="remote"> > > > <cfargument name="testObject" type="struct"> > </cffunction> > > > > > > It works in Flash. Haven't tried it on Flex but > shouldn't have any > > > problems. > > > It is simple if all you want to pass is an > object with some > > > properties instead of sending over a class. > > > > > > > > > -----Original Message----- > > > From: Peter Farland > [mailto:[EMAIL PROTECTED] > > > > > > Sent: Friday, March 25, 2005 11:25 AM > > > To: flexcoders@yahoogroups.com > > > Subject: RE: [flexcoders] How to pass AS Objects > to a CFC > > > > > > > > > The history of this problem stems way back from > > > Flash Remoting in ColdFusion > > > 6.0. > > > > > > ActionScript 1.0 APIs for Flash Remoting > introduced > > > "named arguments" > > > for CF-based invocation. The syntax for passing > > > named arguments was usually > > > listed like this in documentation: > > > > > > myCFService.cfFunction({var1:"foo",var2:"bar"}); > > > > > > > > > Which was intended to match a CFC API: > > > > > > <cffunction name="cfFunction" access="remote"> > > > <cfargument name="var1"> > > > <cfargument name="var2"> > > > </cffunction> > > > > > > The {} syntax, however, really just means an > untyped > > > Object, so this > > > invocation information is lost once it is > serialized > > > over AMF. > > > > > > But AMF isn't the real issue - the Flash > Remoting > > > gateway can't adapt > > > accordinly as it can't get the necessary CFC API > or > > > argument type > > > information from the CFC function before > invoking it > > > (a limitation in CF), > > > so now it has a problem - how would it know that > === message truncated === __________________________________ Do you Yahoo!? Read only the mail you want - Yahoo! Mail SpamGuard. http://promotions.yahoo.com/new_mail Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/flexcoders/ <*> 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/