RE: [flexcoders] How to pass AS Objects to a CFC

2005-03-29 Thread Mehdi, Agha

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=entryentry=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
  you're passing a single
  struct or named arguments?
 
  To disambiguate you use either of the two approaches
  that Mehdi described.
 
 
  

RE: [flexcoders] How to pass AS Objects to a CFC

2005-03-29 Thread Mohanraj Jayaraman

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=entryentry=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 

RE: [flexcoders] How to pass AS Objects to a CFC

2005-03-28 Thread Tom Link

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=entryentry=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
  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: flexcoders@yahoogroups.com
  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: flexcoders@yahoogroups.com
   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 

Re: [flexcoders] How to pass AS Objects to a CFC

2005-03-25 Thread Mohanraj Jayaraman

Thanks Paul. This seems to be a complex project and I
am having a hard time following it. I wish they had a
simple example. But I am still experimenting with
ValueObject.cfc and hope I can get this done pretty
soon.




--- Paul Kenney [EMAIL PROTECTED] wrote:

 At work we figured out how to do this a little while
 back for the
 Tartan Framework (http://www.tartanframework.org).
 If you download the
 code, take a look at the file
 /tartan/vo/ValueObject.cfc, and in
 particular the getFlashRemotingData() and
 setFlashRemotingData()
 methods.
 
 
 
 
 
 
 On Thu, 24 Mar 2005 10:37:27 -0800 (PST), Mohanraj
 Jayaraman
 [EMAIL PROTECTED] wrote:
   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
   
   
   
   --- Dirk Eismann
 [EMAIL PROTECTED]
  
   wrote:
Hi Mohanraj,

CF needs named parameters when dealing with
 complex
types passed as CFC arguments. You have to wrap
 the
object you want to send to the CFC into another
wrapper object. Inside the wrapper you define
properties for every named argument. This
 should
work:

  // AS snippet

  // setup the object to be passed to the CFC
  var o:Object = new Object();
  o.name = Foo;
  o.date = new Date();
  o.otherData = [1,2,3,4,5];

  // create a wrapper for the object
  // input is the named argument of the CFC
  var request = new Object();
  request.input = o;

  // send it
  ro.sendComplexData(request);

The wrapper's input property is also used to
identify the argument inside the CFC:

  !--- CFC snippet ---
  cffunction name=sendComplexData
 access=remote
returntype=string
cfargument name=input type=struct
required=yes 
cfreturn obj.name
  /cffunction

Dirk.


 -Original Message-
 From: Mohanraj Jayaraman
[mailto:[EMAIL PROTECTED]
 Sent: Thursday, March 24, 2005 3:12 AM
 To: flexcoders@yahoogroups.com
 Subject: Re: [flexcoders] How to pass AS
 Objects
to a CFC
 
 
 
 Hi Clint,
 
 Thanks for your reply. I think i was not
 clear
ealrier
 on my problem. Here's a sample code I am
 dealing
with.
 
 Please note the property 'modarray' of the
 'pData'
 object. 
 
 'modarray' is populated with SelTP object _s
 whcih
is
 an Array of Structures. Here I polupate the
 _s
with
 selectedIndices of a data gris I am using.
 
 
 The required parameter 'MODARRAY' not passed
 to
the
 function! is the message I get following my
 RemoteObject call
 
 Any idea what I am missing here.
 

   
   
   
   __ 
   Do you Yahoo!? 
   Yahoo! Small Business - Try our new resources
 site!
   http://smallbusiness.yahoo.com/resources/ 
   
   
   Yahoo! Groups Sponsor 
   
   ADVERTISEMENT
   
   
   
   
   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 the Yahoo!
 Terms of Service. 
 
 
 -- 
 Paul Kenney
 [EMAIL PROTECTED]
 [EMAIL PROTECTED]
 http://www.pjk.us
 




__ 
Do you Yahoo!? 
Make Yahoo! your home page 
http://www.yahoo.com/r/hs


 
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/
 





RE: [flexcoders] How to pass AS Objects to a CFC

2005-03-25 Thread Peter Farland

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: flexcoders@yahoogroups.com
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: flexcoders@yahoogroups.com
 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
 
 
 
 --- Dirk Eismann [EMAIL PROTECTED]
 wrote:
  Hi Mohanraj,
  
  CF needs named parameters when dealing with
 complex types passed as 
  CFC arguments. You have to wrap the object you
 want to send to the CFC 
  into another wrapper object. Inside the wrapper
 you define properties 
  for every named argument. This should
  work:
  
// AS snippet
  
// setup the object to be passed to the CFC
var o:Object = new Object();
o.name = Foo;
o.date = new Date();
o.otherData = [1,2,3,4,5];
  
// create a wrapper for the object
// input is the named argument of the CFC
var request = new Object();
request.input = o;
  
// send it
ro.sendComplexData(request);
  
  The wrapper's input property is also used to
 identify the argument 
  inside the CFC:
  
!--- CFC snippet ---
cffunction name=sendComplexData
 access=remote
  returntype=string
  cfargument name=input type=struct
  required=yes 
  cfreturn obj.name
/cffunction
  
  Dirk.
  
  
   -Original Message-
   From: Mohanraj Jayaraman
  [mailto:[EMAIL PROTECTED]
   Sent: Thursday, March 24, 2005 3:12 AM
   To: flexcoders@yahoogroups.com
   Subject: Re: [flexcoders] How to pass AS Objects
  to a CFC
   
   
   
   Hi Clint,
   
   Thanks for your reply. I think i was not clear
  ealrier
   on my problem. Here's a sample code I am dealing
  with.
   
   Please note the property 'modarray' of the
 'pData'
   object. 
   
   'modarray' is populated with SelTP object _s
 whcih
  is
   an Array of Structures. Here I polupate the _s
  with
   selectedIndices of a data gris I am using.
   
   
   

RE: [flexcoders] How to pass AS Objects to a CFC

2005-03-25 Thread Mehdi, Agha

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 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: flexcoders@yahoogroups.com
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: flexcoders@yahoogroups.com
 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
 
 
 
 --- Dirk Eismann [EMAIL PROTECTED]
 wrote:
  Hi Mohanraj,
  
  CF needs named parameters when dealing with
 complex types passed as 
  CFC arguments. You have to wrap the object you
 want to send to the CFC 
  into another wrapper object. Inside the wrapper
 you define properties 
  for every named argument. This should
  work:
  
// AS snippet
  
// setup the object to be passed to the CFC
var o:Object = new Object();
o.name = Foo;
o.date = new Date();
o.otherData = [1,2,3,4,5];
  
// create a wrapper for the object
// input is the named argument of the CFC
var request = new Object();
request.input = o;
  
// send it
ro.sendComplexData(request);
  
  The wrapper's input property is also used to
 identify the argument 
  inside the CFC:
  
  

RE: [flexcoders] How to pass AS Objects to a CFC

2005-03-25 Thread Mohanraj Jayaraman

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
 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: flexcoders@yahoogroups.com
 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: flexcoders@yahoogroups.com
  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

* 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:

RE: [flexcoders] How to pass AS Objects to a CFC

2005-03-24 Thread Dirk Eismann

Hi Mohanraj,

CF needs named parameters when dealing with complex types passed as CFC 
arguments. You have to wrap the object you want to send to the CFC into another 
wrapper object. Inside the wrapper you define properties for every named 
argument. This should work:

  // AS snippet

  // setup the object to be passed to the CFC
  var o:Object = new Object();
  o.name = Foo;
  o.date = new Date();
  o.otherData = [1,2,3,4,5];

  // create a wrapper for the object
  // input is the named argument of the CFC
  var request = new Object();
  request.input = o;

  // send it
  ro.sendComplexData(request);

The wrapper's input property is also used to identify the argument inside the 
CFC:

  !--- CFC snippet ---
  cffunction name=sendComplexData access=remote returntype=string
cfargument name=input type=struct required=yes 
cfreturn obj.name
  /cffunction

Dirk.


 -Original Message-
 From: Mohanraj Jayaraman [mailto:[EMAIL PROTECTED]
 Sent: Thursday, March 24, 2005 3:12 AM
 To: flexcoders@yahoogroups.com
 Subject: Re: [flexcoders] How to pass AS Objects to a CFC
 
 
 
 Hi Clint,
 
 Thanks for your reply. I think i was not clear ealrier
 on my problem. Here's a sample code I am dealing with.
 
 Please note the property 'modarray' of the 'pData'
 object. 
 
 'modarray' is populated with SelTP object _s whcih is
 an Array of Structures. Here I polupate the _s with
 selectedIndices of a data gris I am using.
 
 
 The required parameter 'MODARRAY' not passed to the
 function! is the message I get following my
 RemoteObject call
 
 Any idea what I am missing here.
 


 
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/
 





RE: [flexcoders] How to pass AS Objects to a CFC

2005-03-24 Thread Mohanraj Jayaraman

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



--- Dirk Eismann [EMAIL PROTECTED]
wrote:
 Hi Mohanraj,
 
 CF needs named parameters when dealing with complex
 types passed as CFC arguments. You have to wrap the
 object you want to send to the CFC into another
 wrapper object. Inside the wrapper you define
 properties for every named argument. This should
 work:
 
   // AS snippet
 
   // setup the object to be passed to the CFC
   var o:Object = new Object();
   o.name = Foo;
   o.date = new Date();
   o.otherData = [1,2,3,4,5];
 
   // create a wrapper for the object
   // input is the named argument of the CFC
   var request = new Object();
   request.input = o;
 
   // send it
   ro.sendComplexData(request);
 
 The wrapper's input property is also used to
 identify the argument inside the CFC:
 
   !--- CFC snippet ---
   cffunction name=sendComplexData access=remote
 returntype=string
 cfargument name=input type=struct
 required=yes 
 cfreturn obj.name
   /cffunction
 
 Dirk.
 
 
  -Original Message-
  From: Mohanraj Jayaraman
 [mailto:[EMAIL PROTECTED]
  Sent: Thursday, March 24, 2005 3:12 AM
  To: flexcoders@yahoogroups.com
  Subject: Re: [flexcoders] How to pass AS Objects
 to a CFC
  
  
  
  Hi Clint,
  
  Thanks for your reply. I think i was not clear
 ealrier
  on my problem. Here's a sample code I am dealing
 with.
  
  Please note the property 'modarray' of the 'pData'
  object. 
  
  'modarray' is populated with SelTP object _s whcih
 is
  an Array of Structures. Here I polupate the _s
 with
  selectedIndices of a data gris I am using.
  
  
  The required parameter 'MODARRAY' not passed to
 the
  function! is the message I get following my
  RemoteObject call
  
  Any idea what I am missing here.
  
 



__ 
Do you Yahoo!? 
Yahoo! Small Business - Try our new resources site!
http://smallbusiness.yahoo.com/resources/ 


 
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/
 





Re: [flexcoders] How to pass AS Objects to a CFC

2005-03-24 Thread Paul Kenney

At work we figured out how to do this a little while back for the
Tartan Framework (http://www.tartanframework.org). If you download the
code, take a look at the file /tartan/vo/ValueObject.cfc, and in
particular the getFlashRemotingData() and setFlashRemotingData()
methods.






On Thu, 24 Mar 2005 10:37:27 -0800 (PST), Mohanraj Jayaraman
[EMAIL PROTECTED] wrote:
  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
  
  
  
  --- Dirk Eismann [EMAIL PROTECTED]
 
  wrote:
   Hi Mohanraj,
   
   CF needs named parameters when dealing with complex
   types passed as CFC arguments. You have to wrap the
   object you want to send to the CFC into another
   wrapper object. Inside the wrapper you define
   properties for every named argument. This should
   work:
   
 // AS snippet
   
 // setup the object to be passed to the CFC
 var o:Object = new Object();
 o.name = Foo;
 o.date = new Date();
 o.otherData = [1,2,3,4,5];
   
 // create a wrapper for the object
 // input is the named argument of the CFC
 var request = new Object();
 request.input = o;
   
 // send it
 ro.sendComplexData(request);
   
   The wrapper's input property is also used to
   identify the argument inside the CFC:
   
 !--- CFC snippet ---
 cffunction name=sendComplexData access=remote
   returntype=string
   cfargument name=input type=struct
   required=yes 
   cfreturn obj.name
 /cffunction
   
   Dirk.
   
   
-Original Message-
From: Mohanraj Jayaraman
   [mailto:[EMAIL PROTECTED]
Sent: Thursday, March 24, 2005 3:12 AM
To: flexcoders@yahoogroups.com
Subject: Re: [flexcoders] How to pass AS Objects
   to a CFC



Hi Clint,

Thanks for your reply. I think i was not clear
   ealrier
on my problem. Here's a sample code I am dealing
   with.

Please note the property 'modarray' of the 'pData'
object. 

'modarray' is populated with SelTP object _s whcih
   is
an Array of Structures. Here I polupate the _s
   with
selectedIndices of a data gris I am using.


The required parameter 'MODARRAY' not passed to
   the
function! is the message I get following my
RemoteObject call

Any idea what I am missing here.

   
  
  
  
  __ 
  Do you Yahoo!? 
  Yahoo! Small Business - Try our new resources site!
  http://smallbusiness.yahoo.com/resources/ 
  
  
  Yahoo! Groups Sponsor 
  
  ADVERTISEMENT
  
  
  
  
  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 the Yahoo! Terms of Service. 


-- 
Paul Kenney
[EMAIL PROTECTED]
[EMAIL PROTECTED]
http://www.pjk.us


 
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/
 





RE: [flexcoders] How to pass AS Objects to a CFC

2005-03-24 Thread Mehdi, Agha

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: flexcoders@yahoogroups.com
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



--- Dirk Eismann [EMAIL PROTECTED]
wrote:
 Hi Mohanraj,
 
 CF needs named parameters when dealing with complex types passed as 
 CFC arguments. You have to wrap the object you want to send to the CFC 
 into another wrapper object. Inside the wrapper you define properties 
 for every named argument. This should
 work:
 
   // AS snippet
 
   // setup the object to be passed to the CFC
   var o:Object = new Object();
   o.name = Foo;
   o.date = new Date();
   o.otherData = [1,2,3,4,5];
 
   // create a wrapper for the object
   // input is the named argument of the CFC
   var request = new Object();
   request.input = o;
 
   // send it
   ro.sendComplexData(request);
 
 The wrapper's input property is also used to identify the argument 
 inside the CFC:
 
   !--- CFC snippet ---
   cffunction name=sendComplexData access=remote
 returntype=string
 cfargument name=input type=struct
 required=yes 
 cfreturn obj.name
   /cffunction
 
 Dirk.
 
 
  -Original Message-
  From: Mohanraj Jayaraman
 [mailto:[EMAIL PROTECTED]
  Sent: Thursday, March 24, 2005 3:12 AM
  To: flexcoders@yahoogroups.com
  Subject: Re: [flexcoders] How to pass AS Objects
 to a CFC
  
  
  
  Hi Clint,
  
  Thanks for your reply. I think i was not clear
 ealrier
  on my problem. Here's a sample code I am dealing
 with.
  
  Please note the property 'modarray' of the 'pData'
  object. 
  
  'modarray' is populated with SelTP object _s whcih
 is
  an Array of Structures. Here I polupate the _s
 with
  selectedIndices of a data gris I am using.
  
  
  The required parameter 'MODARRAY' not passed to
 the
  function! is the message I get following my RemoteObject call
  
  Any idea what I am missing here.
  
 



__
Do you Yahoo!? 
Yahoo! Small Business - Try our new resources site!
http://smallbusiness.yahoo.com/resources/ 


 
Yahoo! Groups Links



 





This email may contain confidential and privileged material for the sole use of 
the intended recipient(s). Any review, use, distribution or disclosure by 
others is strictly prohibited. If you are not the intended recipient (or 
authorized to receive for the recipient), please contact the sender by reply 
email and delete all copies of this message.

To reply to our email administrator directly, send an email to
[EMAIL PROTECTED]

Littler Mendelson, P.C.
http://www.littler.com





 
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/
 





[flexcoders] How to pass AS Objects to a CFC

2005-03-23 Thread Mohanraj Jayaraman

Hi All,

I've been trying to pass an AS Object to a Coldfusion
CFC thorough FLEX RemoteObject calls. But I havent
found any success so far.

I knew there are examples provided my Macromedia for
exchanging complex objects
(http://www.macromedia.com/devnet/flex/articles/complex_data_03.html)
, but they are explained with Java which I am not able
to reproduce the same with Coldfusion CFC's.

Have anybody tried this before? If so,can you explain
it with a simple example?

Thanks,
Mohanraj



__ 
Do you Yahoo!? 
Make Yahoo! your home page 
http://www.yahoo.com/r/hs


 
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/
 





Re: [flexcoders] How to pass AS Objects to a CFC

2005-03-23 Thread Mohanraj Jayaraman

Hi Clint,

Thanks for your reply. I think i was not clear ealrier
on my problem. Here's a sample code I am dealing with.

Please note the property 'modarray' of the 'pData'
object. 

'modarray' is populated with SelTP object _s whcih is
an Array of Structures. Here I polupate the _s with
selectedIndices of a data gris I am using.


The required parameter 'MODARRAY' not passed to the
function! is the message I get following my
RemoteObject call

Any idea what I am missing here.


SelTP.as
--

class SelTP {

var tp : Array;

function SelTP() {
   tp=new Array();
}

function addItem(item : Object,index: Number) :
Void {
index=index==null?0:index;
tp.addItemAt(index, {ID: item.TPID, DE:
item.DES});
}
 function getItemCount() : Number {
return tp.length;
}
}

==
MXML
---

mx:Script
![CDATA[
import SelTP;

var _s:Object;
var myModel: Object;
var updRes:String;

function fn_buildObj():Void {
_s =  new SelTP();
for(var
v:Number=0;vgrd_tp.selectedIndices.length;v++){

_s.addItem(myModel[grd_tp.selectedIndices[v]],_s.getItemCount());
}
   return _s;
}

function fn_repData():Void{
var pData:Object = new Object();
pData.modarray = fn_buildObj();
rob_gD.fn_updData(pData);
}

]]
/mx:Script

mx:RemoteObject id=rob_gD
endpoint=http://127.0.0.1:8500/flashservices/gateway;
 source=MetricportalNew.reus.components.GetNm
showBusyCursor=true
mx:method name=fn_getEmpDets
result=myModel=event.result  /
mx:method name=fn_updData
result=updRes=event.result  /
/mx:RemoteObject

=
CFC
--

cffunction name=fn_updData  returntype=string
access=remote
cfargument name=modarray Type=any
required=true 
cfset var v = Bad data
cfif IsArray(modarray)
cfset v = Array
cfelseif IsObject(modarray)
cfset v = Object
cfelseif IsStruct(modarray)
cfset v = Struct
/cfif
cfreturn v
  /cffunction







--- Clint Tredway [EMAIL PROTECTED] wrote:
 function sendToCF(){
 var send = new Object();
 send.param1 = hello;
 send.param2 =  world;
 your_svc.sayHello(send);
 }
 
 this will show up in the Flash scope inside CF as
 #flash.param1# and
 #flash.param2#..
 
 This is a simple example but it should help you...
 if not I would be
 happy to try and help you figure out what you
 need...
 
 HTH,
 Clint
 
 
 On Wed, 23 Mar 2005 17:41:11 -0800 (PST), Mohanraj
 Jayaraman
 [EMAIL PROTECTED] wrote:
  
  Hi All,
  
  I've been trying to pass an AS Object to a
 Coldfusion
  CFC thorough FLEX RemoteObject calls. But I havent
  found any success so far.
  
  I knew there are examples provided my Macromedia
 for
  exchanging complex objects
 

(http://www.macromedia.com/devnet/flex/articles/complex_data_03.html)
  , but they are explained with Java which I am not
 able
  to reproduce the same with Coldfusion CFC's.
  
  Have anybody tried this before? If so,can you
 explain
  it with a simple example?
  
  Thanks,
  Mohanraj
  
  
  __
  Do you Yahoo!?
  Make Yahoo! your home page
  http://www.yahoo.com/r/hs
  
  Yahoo! Groups Links
  
  
  
  
  
 
 
 -- 
 My Blog
 http://www.clinttredway.com
 
 Are you diabetic?
 http://www.diabetesforums.com
 



__ 
Do you Yahoo!? 
Yahoo! Small Business - Try our new resources site!
http://smallbusiness.yahoo.com/resources/ 


 
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/