Solved

Returning results from remoteobject class to parent

Posted on 2014-11-12
1
225 Views
Last Modified: 2015-05-12
I have a Flex application using ColdFusion to retrieve data from MS SQL. I'm trying to create a class where I can send in a numeric argument and it returns a value to the document calling the class.

This is my class

package com.procost
{
import mx.controls.Alert;
    import mx.core.FlexGlobals;
    import mx.rpc.AbstractOperation;
    import mx.rpc.events.ResultEvent;
    import mx.rpc.remoting.RemoteObject;

    public class EmailListRetrieve
    {
        public var emailListId:Number = -1;

        public function send():void{
            //Create the remote object
            var _remoteObject:RemoteObject = new RemoteObject('test');
            _remoteObject = new RemoteObject("ColdFusion");
            _remoteObject.endpoint = "http://" + FlexGlobals.topLevelApplication.endPointLink + "/flex2gateway/";
            _remoteObject.source = FlexGlobals.topLevelApplication.remotePath + "services.general";
            _remoteObject.showBusyCursor = true;

            //Send
            var op:AbstractOperation = _remoteObject.getOperation('getEmailList');
            op.addEventListener(ResultEvent.RESULT, result);
            op.send(this);
        }

        // Result from CFC
        private function result(event:ResultEvent){
            Alert.show(event.result.toString());
        }
    }
}

Open in new window


This is how I'm calling it from my MXML file

import com.procost.EmailListRetrieve;    

public function fncClick():void{
     var request:EmailListRetrieve = new EmailListRetrieve();
     request.emailListId=1;
     request.send();
}

Open in new window


The result function in my class is returning all the data I need from the DB. The issue is, how do I get this data back into the MXML document I called it from?

Any help would be appreciated.
0
Comment
Question by:RenAndStimpy
1 Comment
 
LVL 28

Accepted Solution

by:
Pravin Asar earned 500 total points
ID: 40439130
After your get result in, assuming you have public variable defined to hold the returned value, got can add
get method

For example:

      public var returnedValue:String;

       // Result from CFC
        private function result(event:ResultEvent){
            Alert.show(event.result.toString());
            setReturnedValue(event.result as String);
        }

       public function setReturnedValue(str:String):void {
             returnedValue = new String (str);
       }
       public function getReturnedValue():String {
             return returnedValue;
       }
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Chocolatey under PowerShell is not working properly 3 60
Change the background and font colors in Notepad++ 5 79
ROBOFTP UNZIP 1 38
ajaxSubmit is giving me an error 1 35
In this tutorial I will show you how to make a simple HTML bar chart with the usage of WhizBase, If you want more information about WhizBase please read my previous articles at http://www.experts-exchange.com/ARTH_5123186.html (http://www.experts-ex…
Today, I was working on some optimization and spam-stopping techniques when I encountered Ben Nadel's post to reduce spam feature using Math (http://www.bennadel.com/blog/197-How-I-Stop-Spammers-On-My-ColdFusion-Blog.htm). While this method is not o…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question