PDA

View Full Version : ColdFusion Component Question


JJSAM
08-13-2008, 09:46 PM
Hi All,
In my CFC I'm trying to get data from the server into my flex app.
<cfcomponent displayname="GapTR.cfc" hint="CFC controls all things Gap Report" output="false">

<cffunction name="getBuyType" access="remote" returntype="xml" output="false">
<cfset var BuyTypeQRY = "">
<cfset var BuyTypeXML = "">
<cfset var parsedBuyTypeXML = "">

<cfquery name="BuyTypeQRY" datasource="gmpwMaster">
SELECT DISTINCT Buy_Type
FROM perseus_AdAssignment
ORDER BY Buy_Type
</cfquery>

<cfset toXML = createObject("component","toXML")>
<cfset BuyTypeXML = toXML.queryToXML(BuyTypeQRY,"dataset","row")>
<cfset parsedBuyTypeXML = xmlParse(BuyTypeXML)>

<cfcontent type="application/xml; charset=UTF-8">

<cfreturn parsedBuyTypeXML />
</cffunction>

</cfcomponent>


and calling this cfc file in mxml....

<mx:Script>
<![CDATA[

[Bindable] public var xmlBuyType:XML;

private function initGap():void {
cfGap.getBuyType();
}

private function saveGap():void {
var BuyType:String;
if( cbBuyType.selectedItem.toString()==''){
Alert.show("Buy Type Unvalid Type")
}
else {
BuyType = cbBuyType.selectedItem.toString();
}
}
public function resultBuyType(event:ResultEvent):void {
xmlBuyType = new XML(event.result);
}
]]>
</mx:Script>
<!--Database Server Connection -->
<mx:RemoteObject id="cfGap" destination="ColdFusion" source="TDB.CFCs.GapTR" showBusyCursor="true">
<mx:method name="getBuyType" result="resultBuyType(event)" fault="Alert.show(event.fault.message)"/>
</mx:RemoteObject>
<mx:Label x="30" y="34" text="Buy Type" id="lblBuyType_cb" fontSize="12" fontWeight="bold"/>
<mx:ComboBox x="10" y="60" width="110" id="cbBuyType" dataProvider="{xmlBuyType.row.Buy_Type}"></mx:ComboBox>

when I run it, I get the following error:

faultCode:Server.Processing faultString:'Could not find the ColdFusion Component toXML.' faultDetail:'Please check that the given name is correct and that the component exists.'

Any Idea why...

Sly_cardinal
08-16-2008, 02:07 PM
I'm guessing that you're using Raymond Camdem's toXML component (http://www.coldfusionjedi.com/projects/toxml/)?

garryrgilbert's response (http://www.ultrashock.com/forums/server-side/coldfusion-component-question-115243.html) to your question on ultrashock.com is correct - ColdFusion can't find the toxml.cfc component file. Move 'toxml.cfc' into the same directory as your 'GapTR.cfc' and it should hopefully work.

JJSAM
08-18-2008, 09:26 PM
thanx