0
votes

I am trying to create a cf component to proxy another one. At the moment the code looks like this: (stripped down for the sake of example):

public MyFuseboxProxy function init( Required any myFb ){
    variables.myFusebox = arguments.myFb;
    return this;
}

this.do = variables.proxy;

private any function proxy(){   
    var local.functionName = getFunctionCalledName();
    var local.function = variables.myFusebox[local.functionName];
    var local.returnVal = local.function( arguments );
    ...
}

As you can see, it's quite straight forward. I pass in my target object at initialisation then use the proxy method to intercept function calls. I am using cfscript, and don't want to use cfinvoke, so am using this approach.

I then call the proxy as follows:

var local.proxy = new ab.MyFuseboxProxy( myFusebox ); 
var local.dump = local.proxy.do ( action='display.body', contentvariable="body" );

However, when I execute the above code I get the following error:

The ACTION argument passed to the do function is not of type string.

If the component name is specified as a type of this argument, it is possible that either a definition file for the component cannot be found or is not accessible.

The error occurred in C:/ColdFusion10/cfusion/wwwroot/fusebox5/myFusebox.cfc: line 301

The error is reported on the target component, so it seems like the function is being called, and the arguments passed through, but the type is not being preserved/recognised as a String.

Can anyone advise what I am doing wrong or how I can preserve the argument types?

1

1 Answers

1
votes

Yup, I suspect instead of this:

var local.returnVal = local.function( arguments );

You mean this:

var local.returnVal = local.function(argumentCollection=arguments );

Your current code is passing the arguments as the first argument, rather than passing them as they were originally passed in.