Malcom,

I think that's it.

Try this:

var call = service.login( { loginVO : loginVO } );
//strange looking syntax huh, but it works

You see the anon object which is naming the param.  It took us ages to
figure this one out.  

There is an article which describes this here:

http://www.flexingcfmx.com/index.cfm?mode=entry&entry=D36D5CE5-FB00-283B-A23
A89CB46949A4D

Hope this helps,
Allen
www.prismix.com/



-----Original Message-----
From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Malcolm
Sent: 25 July 2005 22:52
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders] Using Value Objects & CFC's

Hi Allen,

I am using the Cairngorm framework and calling the CFC inside my
LoginDelegate (via a service)

---- Part of LoginDelegate.as ----

public function login( loginVO : LoginVO ): Void
        {
        // call login service, pass loginVO     
        var call = service.login( loginVO );
                
        call.resultHandler = Delegate.create(responder, responder.onResult);
        call.faultHandler = Delegate.create(responder, responder.onFault);
        }

Is this my problem?

var call = service.login( loginVO );

----- This is my LoginService CFC ----

<cfcomponent displayname="LoginService">

        <cffunction name="login" output="false" access="remote">
        <cfargument name="loginVO" type="LoginVO" required="yes" default="">
                
                <!--- THIS DOESN'T WORK --->
                <cfset username = loginVO.username>
        
        </cffunction>

</cfcomponent>

It would be awesome if I could get this working, right now I am resorting to
building toArray() functions in my Flex value objects and calling my CFC
like this:

var call = service.login( loginVO.toArray() );

Muchos gracias,
Malcolm

-----Original Message-----
From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Allen Manning
Sent: Tuesday, 26 July 2005 3:11 AM
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders] Using Value Objects & CFC's

Malcolm,

We are doing this very thing and it is working well for us.  

We use CFCs as our VOs and it allows us to type them in and out of CFC
method calls.

Can you post how the CFC is being called by Flex?  You need to use an anon
object with a named param, so this might be the problem.  

Allen
http://www.prismix.com/




-----Original Message-----
From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Malcolm
Sent: 24 July 2005 11:31
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders] Using Value Objects & CFC's

For the record, I did end up trying Approach 1. Doesn't work, exactly the
same error as before:

Error Type: Expression
Message: You have attempted to dereference a scalar variable of type

Unless I am missing something, I think it's fair to say when using CF as a
backend for Flex applications you can not pass your own data types.

m

-----Original Message-----
From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Malcolm
Sent: Sunday, 24 July 2005 3:56 PM
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders] Using Value Objects & CFC's

Ok think I am going to have to admit defeat here, I have now tried the
following...I have created a cfc version of the Login Value Object.

---- LoginVO.cfc ----

<cfcomponent>
   <cfproperty name="username" type="string">
   <cfproperty name="password" type="string">
</cfcomponent>

----- CFC ----

<cfcomponent displayname="LoginService">

        <cffunction name="login" output="false" access="remote">
        <cfargument name="loginVO" type="LoginVO" required="yes" default="">
                
                <!--- THIS STILL DOESN'T WORK --->
                <cfset username = loginVO.username>
        
        </cffunction>

</cfcomponent>

I still get the same error as before...

Error Type: Expression
Message: You have attempted to dereference a scalar variable of type

I assume this is because I am passing in a Flex/Java object of the type
'LoginVO' and this is just not the same as a ColdFusion object of the type
'LoginVO' (as defined in LoginVO.cfc).

I really don't want to give up using value objects on the Flex side, as I
may one day move the backend of the application from cf to java.

I think I am going to have to give up on trying to define a cf version of my
value object and take one of the following approaches:

1. Create a Java Value Object in ColdFusion using the CreateObject function
in cf. Assign the Flex Value Object Data to the Java Value Object (created
via ColdFusion). Then access the values of cf/java object. I have no idea if
this will actually work! May just end up with the same error again :{

2. In my Flex value object have a "function toArray()" call that and then
pass to my cfc remote object. Yes would require going around every remote
service call sometime in the future when I go to java and removing such
calls.

Hmmm, re-reading my email, approach 1 really is madness, even if it did
work, it's a lot of work for the sake of being able to pass a flex/java
value object to a cfc (I am still going to have to pull the sucker to pieces
inside cf anyway), so I am not going to bother with this.

What does everyone else do here? Only pass data types that are supported by
cf argument? Any suggested best practice?

Comments welcome :D

Cheers,
M

-----Original Message-----
From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Douglas Knudsen
Sent: Sunday, 24 July 2005 7:32 AM
To: flexcoders@yahoogroups.com
Subject: Re: [flexcoders] Using Value Objects & CFC's

a CFC can except "types" defined by another CFC.  In the cfargumnet
tag use the CFC name, dot.noted.paths.are.ok.too.

<cfargument name="bugVO" type="com.foo.buggy.bugVO" rewuired="true" />

Note, the CFC method can also return "types" defined by CFCs too.


DK


On 7/23/05, Tariq Ahmed <[EMAIL PROTECTED]> wrote:
> Hey Malcolm. Well CFC's generally only accept datatypes they understand:
> boolean, string, numeric, array, struct, etc...
> 
> This article may give you a head start:
>
http://www.flexingcfmx.com/index.cfm?mode=entry&entry=D36D5CE5-FB00-283B-A23
A89CB46949A4D
> 
> 
> Malcolm wrote:
> 
> >Hi yo'll
> >
> >I am using Remote Objects (definitely the way to go) with ColdFusion 7
> >(CFC). I have no problems passing strings to a CFC but can't seem to be
able
> >to use Value Objects, is this possible?
> >
> >Or put another way can a CFC argument be of the type Object? Using
example
> >code from the Cairngorm login sample, this is the object I am passing to
the
> >CFC.
> >
> >---- LoginVO.as ----
> >
> >import org.nevis.cairngorm.vo.ValueObject;
> >class com.company.product.vo.LoginVO implements ValueObject
> >{
> >       public function toString() : String
> >       {
> >           var s : String = "LoginVO[username=";
> >           s += username;
> >           s += ", password=";
> >           s += password;
> >           s += ", loginDate=";
> >           s += loginDate;
> >           s += " ]";
> >           return s;
> >       }
> >
> >       public static var registered:Boolean = Object.registerClass( "
> >com.company.product.vo.LoginVO", LoginVO );
> >
> >       public var username : String;
> >       public var password : String;
> >       public var loginDate : Date;
> >}
> >
> >----- CFC ----
> >
> ><cfcomponent displayname="LoginService">
> >
> >       <cffunction name="login" output="false" access="remote">
> >
> >               <cfargument name="loginVO" required="yes" default="">
> >
> >               <!--- THIS DOESN'T WORK --->
> >               <cfset username = loginVO.username>
> >
> >       </cffunction>
> >
> ></cfcomponent>
> >
> >---- Generates the following CF Error ----
> >
> >Error Type: Expression
> >Message: You have attempted to dereference a scalar variable of type
class
> >java.lang.String as a structure with members.
> >
> >-----
> >
> >Something wrong with the way I am accessing the loginVO.username value?
Do I
> >need to perform a deep copy of the object or something like that?
> >
> >Any thoughts appreciated.
> >
> >Regards,
> >Malcolm
> >
> >
> >
> >
> >
> >--
> >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
> >
> >
> >
> >
> >
> >
> >
> >
> >
> 
> 
> 
> 
> 
> --
> 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
> 
> 
> 
> 
> 
> 
> 


-- 
Douglas Knudsen
http://www.cubicleman.com
this is my signature, like it?


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



 






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



 




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



 



-- 
Incoming mail is certified Virus Free.
Checked by AVG Anti-Virus (http://www.grisoft.com).
Version: 7.0.269 / Virus Database: 267.9.2 - Release Date: 19/07/2005
 

-- 
Outgoing mail is certified Virus Free.
Checked by AVG Anti-Virus (http://www.grisoft.com).
Version: 7.0.269 / Virus Database: 267.9.4 - Release Date: 22/07/2005
 



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



 




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



 


-- 
Incoming mail is certified Virus Free.
Checked by AVG Anti-Virus (http://www.grisoft.com).
Version: 7.0.269 / Virus Database: 267.9.5 - Release Date: 25/07/2005
 

-- 
Outgoing mail is certified Virus Free.
Checked by AVG Anti-Virus (http://www.grisoft.com).
Version: 7.0.269 / Virus Database: 267.9.5 - Release Date: 25/07/2005
 



--
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/

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


Reply via email to