我想創建一個cf組件來代理另一個。目前代碼如下所示:(爲簡單起見,剝離):通過代理調用函數
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);
...
}
正如您所看到的,它非常簡單。我在初始化時傳入目標對象,然後使用代理方法攔截函數調用。我正在使用cfscript,並不想使用cfinvoke,所以我正在使用這種方法。
我然後調用代理如下:
var local.proxy = new ab.MyFuseboxProxy(myFusebox);
var local.dump = local.proxy.do (action='display.body', contentvariable="body");
然而,當我執行上面的代碼中,我得到以下錯誤:
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
報道目標組件上的錯誤,所以它看起來像函數被調用,並通過參數傳遞,但類型不被保存/識別爲一個字符串。
任何人都可以建議我做錯了什麼或我如何保存參數類型?
當然,小學生的錯誤..謝謝。 – rhinds