Whenever you use a remote object you don't set the event type of the
function to an Object you set it to ResultEvent so your result function
needs to look like this

private function getJobResult(event:ResultEvent):void{

Secondly I think the first thing you should do is see if you are actually
getting a result back from your CFC. So an easy way to do that would be to
do

import mx.controls.Alert;
private function getJobResult(event:ResultEvent):void{
    Alert.show(event.result.length.toString());
}

Should get an alert box with a number, if you don't get an alert at all then
you know flex isn't even hitting the result function.

On 3/5/07, Piotrowski, John <[EMAIL PROTECTED]> wrote:

   Are you sure the data is coming back from the remote object properly
and it is in the right format?  I would try to set a breakpoint private
function getJobResult(event:Object):void and then look at the event object
in the debugger.



Also try replacing the getJobResult with



private function getJobResult(event:Object):void{
jobs = event.result["RESULTS"] as ArrayCollection;
}



and move the Bindable jobs… to the top right after the import statements.



You have a databinding to the variable jobs and this is bound to the
comboBox, so the result of the remoteobject should update this bound jobs
variable and then it will update the combobox automatically.



John



**************************************************

 John R. Piotrowski

 Programmer Analyst

 Wharton Computing

 Email: [EMAIL PROTECTED]

**************************************************


 ------------------------------

*From:* [email protected] [mailto:[EMAIL PROTECTED] *On
Behalf Of *April
*Sent:* Monday, March 05, 2007 10:20 AM
*To:* [email protected]
*Subject:* [flexcoders] Re: Populate ComboBox from database - NOT using
Flex Data Services



Thank you for everyone's responses, but I'm still not having any luck. I'm
not getting any
errors - but my combobox is not populating. Again, I'm really new to Flex.

My app is called PreTraffic with the following structure:

PreTraffic
cfc (folder)
job.cfc
JobSearch.cfc

**********************************************************

job.cfc contatins:

<cfcomponent>
<!--- Get jobs --->
<cffunction name="GetJob" access="remote" returntype="query"
output="false">

<cfset var job="">
<cfset var results="">

<cfquery datasource="discsdev" name="job">
SELECT job_id, job_title
FROM job
WHERE status = 'O'
ORDER BY job_title
</cfquery>
<cfquery dbtype="query" name="results">
SELECT job_title AS label, job_id AS data
FROM job
ORDER BY label
</cfquery>
<cfreturn results>
</cffunction>
</cfcomponent>

**************************************************************

JobSearch.mxml contains:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml";
xmlns="*"
layout="absolute"
backgroundGradientColors="[#ffffff, #d0d0d0]"
creationComplete="InitApp()">

<mx:Style source="style.css" />

<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.rpc.events.ResultEvent;

public function InitApp():void {
jobSvc.GetJob();
}

private function getJobResult(event:Object):void{
jobNameCB.dataProvider = event.result as ArrayCollection;
}

[Bindable]
private var jobs:ArrayCollection = new ArrayCollection();

private function jobHandler(event:ResultEvent):void{
jobs = event.result.catalog.job;
var jobObj:Object = new Object();
jobObj.name = "All";
jobObj.jobID = 0;
jobs.addItemAt(jobObj, 0);
jobNameCB.selectedIndex = 0;
}
]]>
</mx:Script>

<!-- ColdFusion CFC (via AMF) -->
<mx:RemoteObject id="jobSvc" destination="ColdFusion" source="
PreTraffic.cfc.job"
showBusyCursor="true">
<mx:method name="GetJob" result="getJobResult(event)"/>
</mx:RemoteObject>

<mx:VBox label="Job History" width="100%" height="100%" x="10" y="92">
<mx:FormItem label="Job Name:">
<mx:ComboBox id="jobNameCB" dataProvider="{jobs}"
labelField="{data}">
</mx:ComboBox>
</mx:FormItem>
</mx:Form>
<mx:HBox>
<mx:Button label="Search"/>
<mx:Button label="Clear"/>
</mx:HBox>

</mx:VBox>
</mx:Application>

Reply via email to