I am trying to build a method call from strings that were passed to an object belonging to another object.
usually when calling an object, we write the code as follows:
application.stObj.oNewsBusiness.getNews(argumentCollection=local.stArgs);
However, what I did is creating an array containing the name of the object, the name of the method, and a collection of arguments.
<cfscript> local.stArgs = {}; local.stArgs.nNewsID = 19; local.stArgs.sAuthor = "John"; local.aData = []; local.aData[1] = local.stArgs; local.aData[2] = "stObj.oNewsBusiness"; local.aData[3] = "getNews"; </cfscript>
however, I am struggling to re-arrange all this as a method call.
UPDATE using a sentence but still with a question
While cfinvoke seems to work for:
<cfinvoke component="#application.stObj.oNewsBusiness#" method="#local.sMethod#" argumentcollection="#local.stArgs#" returnvariable="local.qData"></cfinvoke>
it does not work when doing something like:
<cfscript> local.stArgs = local.aData[1]; local.sObject = local.aData[2]; local.sMethod = local.aData[3]; </cfscript> <cfinvoke component="application.#local.sObject#" method="#local.sMethod#" argumentCollection="#local.stArgs#" returnvariable="local.qData"></cfinvoke>
it generates an error:
Could not find ColdFusion component or application.stObj.oNewsBusiness interface
source share