0 Replies Latest reply on Dec 5, 2007 12:41 PM by mark416

    RemoteObject function in Cairngorm?

    mark416 Level 1
      Hi,

      I am using Cairngorm with CFC now.

      my delegate code and serves.mxml code are here:

      form3Delegate.as

      package ca.sb.CESF.Bursary.business {

      import com.adobe.cairngorm.business.ServiceLocator;
      import mx.rpc.IResponder;
      import ca.sb.CESF.Bursary.vo.PersonVO;
      import mx.controls.Alert;

      public class Form3Delegate {

      private var responder:IResponder;
      private var service:Object;

      public function Form3Delegate( responder:IResponder ) {

      Alert.show("login delegate begine");
      this.responder = responder;
      this.service = ServiceLocator.getInstance().getRemoteObject("BursaryService");
      Alert.show("login delegate done");
      }

      public function AddPersonData(personVO:PersonVO):void {
      Alert.show("DELEGATE " + personVO.firstname);
      var call:Object = this.service.addPerson(personVO);
      call.addResponder(responder);

      }

      public function ShowPerson(personData:String):void {

      var call:Object = this.service.showPerson(personData);
      call.addResponder( responder );

      }

      }
      }

      services.mxml

      <?xml version="1.0" encoding="utf-8"?>
      <cairngorm:ServiceLocator
      xmlns:mx=" http://www.adobe.com/2006/mxml"
      xmlns:cairngorm="com.adobe.cairngorm.business.*">

      <!-- Bursary Service -->
      <mx:RemoteObject
      id="BursaryService"
      destination="ColdFusion"
      source="CESF_Bursary.cfcs.BursaryProcess">

      <mx:method name="addPerson" result="hresult()" fault="hfault(event)"/>
      <mx:method name="showPerson" result="hresult()" fault="hfault(event)"/>

      </mx:RemoteObject>
      <mx:Script>
      <![CDATA[

      import mx.controls.Alert;
      import mx.rpc.events.FaultEvent


      private function hresult():void{
      Alert.show("add ok")
      }

      private function hfault(event:FaultEvent):void{
      Alert.show(event.fault.toString())

      }
      ]]>
      </mx:Script>

      </cairngorm:ServiceLocator>


      addPerson.cfc

      <cfcomponent displayname="BursaryProcess" hint="CFC to process applications" output="false">

      <cffunction name="addPerson" displayname="addPerson" access="remote" output="false" returntype="boolean">
      <cfargument name="personVO" type=" PersonVO" required="true" />

      <cfquery name="insertPerson" datasource="bursary">
      INSERT INTO person_info (fname,
      lname,
      sid)
      VALUES('#personVO.firstname#',
      '#tpersonVO.lastname#',
      '#personVO.sid#')
      </cfquery>

      <cfreturn true />

      </cffunction>

      <cffunction name="showPerson" displayname="addPerson" access="remote" output="false" returntype="boolean">
      <cfargument name="person" type="string" required="true" />
      <cfreturn true />
      </cffunction>

      </cfcomponent>

      personVO.cfc

      <cfcomponent displayname="PersonVO" hint="Login VO For CairngormTest" output="false">

      <cfproperty name="firstname" type="string" default="">
      <cfproperty name="lastname" type="string" default="">
      <cfproperty name="sid" type="string" default="">

      <cfscript>
      //Initialize the CFC with the default properties values.
      variables.firstname = "";
      variables.lastname = "";
      variables.sid = "";
      </cfscript>

      <cffunction name="init" output="false" returntype="PersonVO">
      <cfreturn this>
      </cffunction>
      <cffunction name="getFirstname" output="false" access="public" returntype="any">
      <cfreturn variables.Firstname>
      </cffunction>

      <cffunction name="setFirstname" output="false" access="public" returntype="void">
      <cfargument name="val" required="true">
      <cfset variables.Firstname = arguments.val>
      </cffunction>

      <cffunction name="getLastname" output="false" access="public" returntype="any">
      <cfreturn variables.Lastname>
      </cffunction>

      <cffunction name="setLastname" output="false" access="public" returntype="void">
      <cfargument name="val" required="true">
      <cfset variables.Lastname = arguments.val>
      </cffunction>

      <cffunction name="getSid" output="false" access="public" returntype="any">
      <cfreturn variables.Sid>
      </cffunction>

      <cffunction name="setSid" output="false" access="public" returntype="void">
      <cfargument name="val" required="true">
      <cfset variables.Sid = arguments.val>
      </cffunction>


      </cfcomponent>


      I output data with "Alert.show( "DELEGATE " + personVO.firstname) " in
      function AddPersonData. I can get output data. that is ok

      but I get error when I pass data by "call:Object =
      this.service. addPerson( personVO) ;"

      The Error message like following

      [RPC Fault faultString= "Element FIRSTNAME is undefined in PERSONVO."
      faultCode="Server. Processing" faultDetail= ""]

      I need to know which function in RemoteObject tag can show which data is passed to addPerson function exactly? what I get the error. I believe I pass right data in delegate function.

      Thanks

      Mark