Question

I have this block of actionscript code which is executed when a login is appempted. I an trying to reload a set of roles for a the user. I've added a result handler to the hasRole() method

[Observer("loginAttempted")]
public function loginAttempted():void {
    identity.isLoggedIn(isLoggedInResult);

    trace(identity.loggedIn+" "+identity.username);
    var perms:Array = Permission.constants;
    var i:int
    trace("Load permissions");
    for(i=0;i<perms.length;i++)
    {
        var p:Permission = perms[i];
        var res = identity.hasRole(p.name,permissionResult);
        if(res == true)
        {
            p.allowed = res;
        }
        trace(i+" "+p.name +" "+p.allowed+" "+res);
    }
}

private function permissionResult(event:TideResultEvent):void {
    trace("permissionResult "+event.result);
}

but i keep getting this error. Based on the graniteds docs the function should only take a single argument.

[Fault] exception, information=ArgumentError: Error #1063:
Argument count mismatch on Main/permissionResult(). Expected 1, got 2.
at TideRoleResponder/result()[C:\workspace\graniteds\as3\framework\org\granite\tide\ejb\Identity.as:201]
at org.granite.tide::Tide/result()[C:\workspace\graniteds\as3\framework\org\granite\tide\Tide.as:1831]
at org.granite.tide.rpc::ComponentResponder/result()[C:\workspace\graniteds\as3\framework\org\granite\tide\rpc\ComponentResponder.as:65]
at mx.rpc::AsyncToken/http://www.adobe.com/2006/flex/mx/internal::applyResult()[C:\autobuild\3.5.0\frameworks\projects\rpc\src\mx\rpc\AsyncToken.as:199]
at mx.rpc.events::ResultEvent/http://www.adobe.com/2006/flex/mx/internal::callTokenResponders()[C:\autobuild\3.5.0\frameworks\projects\rpc\src\mx\rpc\events\ResultEvent.as:172]
at mx.rpc::AbstractOperation/http://www.adobe.com/2006/flex/mx/internal::dispatchRpcEvent()[C:\autobuild\3.5.0\frameworks\projects\rpc\src\mx\rpc\AbstractOperation.as:199]
at org.granite.tide.rpc::TideOperation/http://www.adobe.com/2006/flex/mx/internal::dispatchRpcEvent()[C:\workspace\graniteds\as3\framework\org\granite\tide\rpc\TideOperation.as:73]
at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::resultHandler()[C:\autobuild\3.5.0\frameworks\projects\rpc\src\mx\rpc\AbstractInvoker.as:263]
at mx.rpc::Responder/result()[C:\autobuild\3.5.0\frameworks\projects\rpc\src\mx\rpc\Responder.as:46]
at mx.rpc::AsyncRequest/acknowledge()[C:\autobuild\3.5.0\frameworks\projects\rpc\src\mx\rpc\AsyncRequest.as:74]
at NetConnectionMessageResponder/resultHandler()[C:\autobuild\3.5.0\frameworks\projects\rpc\src\mx\messaging\channels\NetConnectionChannel.as:524]
at mx.messaging::MessageResponder/result()[C:\autobuild\3.5.0\frameworks\projects\rpc\src\mx\messaging\MessageResponder.as:199]
Was it helpful?

Solution

We are using the ifAnyGranted function on the identity to do something similar, and our result handler has 2 arguments: the TideResultEvent, and a String containing the role. Try changing the signature of the permissionResult function to:

private function permissionResult(event:TideResultEvent, role:String):void
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top