Return own CFC to Flex/Flash

Discussion in 'Programming' started by maeldanus, Aug 11, 2009.

  1. #1
    Hi,

    i am a flex-Developer (and Air) and playing around with coldfusion...

    My Problem:
    I want to read out a Database (MySQL) with Coldfusion - So far, no problem. Now i want to return the results as personal Objects to Flash.

    Detail:

    I have a Component wich represents a user

    <cfcomponent displayname="CurrentUserVO" hint="Represents the logged in User" output="false">
    	<cfset this.username = "" />
    	<cfset this.password = "" />
    	
    	<cfset this.firstname = "" />
    	<cfset this.lastname = "" />
    </cfcomponent>
    PHP:
    (In Flex there is a "linked" Class with the same Content)


    <cfcomponent hint="Exchange" output="false">
    
    <cfobject name="currentuserVO" component="CurrentUserVO">
    
    <!-- cfc property names -->
    
    
    	<cffunction name="login" displayname="login" access="remote" output="false" >
    			<cfargument name="username"  required="true"  type="String">
    			<cfargument name="password"  required="true"  type="String">
    				
    				
    				<cfquery name="Meinquery" datasource="cfagency" username="root" password="">
    					SELECT * FROM user WHERE username= '#username#' AND password = '#password#'
                    </cfquery>
    							
    				
    				<cfif isDefined("query")>
    					<cfscript>
    						currentuserVO.username 	= Meinquery.username;
    						currentuserVO.password 	= Meinquery.password;
    						currentuserVO.firstname = Meinquery.firstname;
    						currentuserVO.lastname 	= Meinquery.lastname;	
                        </cfscript>
    					
    					<cfreturn #currentuserVO# >
    				
    				<cfelse>
    					<cfreturn "false" >
                    </cfif>				
    				
    	</cffunction>
    PHP:
    That doesn't work... :(

    Strange: I can return the whole query and i can reutrn for example "currentuserVO.lastname"

    But why i can't return currentUserVO ???

    Greetings from Germany, nico :)
     
    maeldanus, Aug 11, 2009 IP
  2. maeldanus

    maeldanus Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Nobody knows?

    It would be great, if someone can help me. (I can't imagine that this is so complicated?
     
    maeldanus, Aug 13, 2009 IP
  3. Paul_K

    Paul_K Greenhorn

    Messages:
    85
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    18
    #3
    <cfreturn currentuserVO >

    Should work just fine. You don't need that # #

    Note that you should add a return type in the function name.
     
    Paul_K, Aug 18, 2009 IP