Hi,
I am trying to learn to use Cairngorm and I am trying to find out where
I am going wrong. I have a CFC which I am trying to call and get a
string back for testing to make sure its all working. The delegate
should call the result or the fault function in my LoginUserCommand if I
am correct. I am trying to see if the problem is the call to the CFC or
the problem is in my LoginUserCommand which has functions that should
handle the result or a fault.
I have this in my "LoginUserDelegate"
package com.adobe.myApp.business {
import mx.rpc.AsyncToken;
import mx.rpc.IResponder;
import com.adobe.cairngorm.business.ServiceLocator;
import mx.controls.Alert;
public class LoginUserDelegate {
private var command : IResponder;
private var service : Object;
public function LoginUserDelegate( command : IResponder ) {
this.service = ServiceLocator.getInstance().getService(
'loginUserService' );
this.command = command;
}
public function loginUserService() : void {
var token:AsyncToken = service.send();
token.addResponder( command );
}
}
}
My services.xml:
<?xml version="1.0" encoding="utf-8"?>
<cairngorm:ServiceLocator
xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:cairngorm="com.adobe.cairngorm.business.*">
<mx:RemoteObject
id="loginUserService"
destination="Coldfusion"
source="cf.com.User"
showBusyCursor="true" >
<mx:method name="sayHelloString" />
</mx:RemoteObject>
Then I have a "LoginUserCommand":
package com.adobe.myApp.command {
import mx.rpc.IResponder;
import com.adobe.cairngorm.commands.Command;
import com.adobe.cairngorm.control.CairngormEvent;
import com.adobe.myApp.business.LoginUserDelegate;
import com.adobe.myApp.model.AppModelLocator;
public class LoginUserCommand implements Command, IResponder {
private var model : AppModelLocator = AppModelLocator.getInstance();
public function execute( loginEvent:CairngormEvent ) : void {
var delegate : LoginUserDelegate = new LoginUserDelegate( this );
delegate.loginUserService();
}
// this is called when the delegate receives a result from the service
public function result( rpcEvent : Object ) : void {
trace(rpcEvent.result);
}
public function fault( rpcEvent : Object ) : void {
model.errorStatus = "Fault occured in LoadEmployeesCommand.";
}
}
}
</cairngorm:ServiceLocator>