Hi guys,

I have this very strange problem: here's my code for those that are willing
to help:



<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"; layout="absolute">

 <mx:Script>
  <![CDATA[
   import mx.rpc.events.ResultEvent;
   import mx.controls.Alert;

   private function submitForm():void {
    var params:Object = new Object();
    params.firstName = firstName.text;
    params.lastName = lastName.text;
    myService.insertArtist(params);
   }

   private function myResultHandler(event:ResultEvent):void {
    if (Boolean(event.result) == true) {
     Alert.show("New Artist added!!");
    } else {
     Alert.show("Error");
    }
   }

  ]]>
 </mx:Script>


 <mx:RemoteObject id="myService" destination="ColdFusion" source="
RemoteObject.cfc.queries"
    result="myResultHandler(event)"  showBusyCursor="true" />


 <mx:Form>
  <mx:FormItem>
   <mx:Label text="First Name" />
   <mx:TextInput id="firstName" />
  </mx:FormItem>
  <mx:FormItem>
   <mx:Label  text="Last Name" />
   <mx:TextInput id="lastName" />
  </mx:FormItem>
  <mx:FormItem>
   <mx:Button label="Submit" click="submitForm();" />
  </mx:FormItem>
 </mx:Form>

</mx:Application>



and my simple CFC contains....

<cffunction name="insertArtist" access="remote" returntype="boolean">
  <cfargument name="firstName" type="string">
 <cfargument name="lastName" type="string">

 <cfset success = true>

 <cftry>
  <cfquery name="qInsertArtist" datasource="flexdata">
   insert into tbl_test (firstName,lastName)
   values ('#arguments.firstName#','#arguments.lastName#')
  </cfquery>
  <cfcatch type="database">
   <cfset success = false>
  </cfcatch>
 </cftry>

 <cfreturn success>
 </cffunction>



Notice that even if I enter to the end of my cffunction the <cfreturn
false>, my myResultHandler always returns a "New Artist Added" (meaning that
it always report true). The tbl_test table does not even exist!!! How is it
possible to get a 'True' message from Flex? is that kind of a bug? Or am I
doing something wrong? I used to have a similar problem when using an
HTTPService.

Thanks for your help, really helpful :)

George

Reply via email to