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: [email protected]
> 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: [email protected]
> > 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
> > you're passing a single
> > struct or named arguments?
> >
> > To disambiguate you use either of the two approaches
> > that Mehdi described.
> >
> >
> > -----Original Message-----
> > From: Mohanraj Jayaraman
> > [mailto:[EMAIL PROTECTED]
> > Sent: Friday, March 25, 2005 2:12 PM
> > To: [email protected]
> > Subject: RE: [flexcoders] How to pass AS Objects to
> > a CFC
> >
> >
> > WOW! It works Mehdi. As you pointed out the second
> > variable passed in the CFC function call did the
> > magic! If possible, an explanation on why it works
> > with the second variable will be more useful Mehdi.
> >
> > My guess is that one should have good knowledge of
> > Flash/ActionScript before venturing into doing any
> > complex stuff with FLEX.
> >
> > Thanks a lot sharing this.
> >
> > Mohanraj
> >
> >
> >
> >
> >
> > --- "Mehdi, Agha" <[EMAIL PROTECTED]> wrote:
> >
> > > Mohanraj,
> > >
> > > I learned it the hard way. There are two ways to
> > do
> > > it.
> > >
> > > 1.
> > > Flex side:
> > >
> > > var toPass = new MyClass();
> > >
> > > toPass.var1 = "value";
> > > toPass.var2 = "value";
> > >
> > > remoteObject.cfFunction ( toPass );
> > >
> > > CF Side:
> > >
> > > <cffunction name="cfFunction" access="remote">
> > > <cfargument name="var1">
> > > <cfargument name="var2">
> > > </cffunction>
> > >
> > > I'm sure it's not acceptable.
> > >
> > > 2.
> > > Flex Side:
> > >
> > > var toPass = new MyClass();
> > >
> > > toPass.var1 = "value";
> > > toPass.var2 = "value";
> > >
> > > remoteObject.cfFunction ( toPass, true );
> > >
> > > CF Side:
> > >
> > > <cffunction name="cfFunction" access="remote">
> > > <cfargument name="toPass">
> > > </cffunction>
> > >
> > > That works beautifully. The second arg from Flex
> > > doesn't have to be a
> > > boolean but it just easy to type.
> > >
> > > Please let me know if that works.
> > >
> > > -----Original Message-----
> > > From: Mohanraj Jayaraman
> > > [mailto:[EMAIL PROTECTED]
> > > Sent: Thursday, March 24, 2005 10:37 AM
> > > To: [email protected]
> > > Subject: RE: [flexcoders] How to pass AS Objects
> > to
> > > a CFC
> > >
> > >
> > > Hi Dirk,
> > >
> > > Thanks for your suggestion. But my condition
> > differs
> > > from your example.
> > >
> > > Lets assume I had an AS Class 'MyClass.as'
> > > I am trying to do something like this in my MXML
> > > var o:Object = new MyClass();
> > > I build an 'array of structures' in MyClass
> > Object
> > > and I do pass the
> > > complex Object as input with another Object
> > wrapper.
> > >
> > > Here's an example by Macromedia on how exchange
> > > complex data
> > >
> > >
> >
> http://www.macromedia.com/devnet/flex/articles/complex_data_03.html
> > >
> > > According to macromedia
> > > When invoking methods remotely, you can pass
> > objects
> > > back and forth (as the
> > > methods' input parameters and return value)
> > between
> > > the client and the
> > > server.
> > >
> > > This example is explained with Java and I am
> > trying
> > > to replicate the same
> > > with Coldfusion CFC's.
> > >
> > > Thanks,
> > > Mohanraj
> > >
> > >
> > >
> >
> === message truncated ===
>
>
>
>
> __________________________________
> Do you Yahoo!?
> Yahoo! Small Business - Try our new resources site!
> http://smallbusiness.yahoo.com/resources/
>
>
>
> Yahoo! Groups Links
>
>
>
>
>
>
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/