Note that there are some explanatory texts on larger screens.

plurals
  1. POcoldfusion 9 dynamically call method
    primarykey
    data
    text
    <p>I'm attempting to build a method call from strings that have been passed into an object that refer to another object.</p> <p>normally when calling an object we write the code like this:</p> <pre><code>application.stObj.oNewsBusiness.getNews(argumentCollection=local.stArgs); </code></pre> <p>However what I have done is created an array that contains the object name, the method name and the argument collection.</p> <pre><code>&lt;cfscript&gt; 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"; &lt;/cfscript&gt; </code></pre> <p>however i am struggling to recombine all this to be a method call.</p> <p><strong>UPDATE using suggestion but still with issue</strong></p> <p>While cfinvoke seems to work for:</p> <pre><code>&lt;cfinvoke component="#application.stObj.oNewsBusiness#" method="#local.sMethod#" argumentcollection="#local.stArgs#" returnvariable="local.qData"&gt;&lt;/cfinvoke&gt; </code></pre> <p>it doesn't work when doing something like:</p> <pre><code>&lt;cfscript&gt; local.stArgs = local.aData[1]; local.sObject = local.aData[2]; local.sMethod = local.aData[3]; &lt;/cfscript&gt; &lt;cfinvoke component="application.#local.sObject#" method="#local.sMethod#" argumentCollection="#local.stArgs#" returnvariable="local.qData"&gt;&lt;/cfinvoke&gt; </code></pre> <p>it generates an error: </p> <blockquote> <p>Could not find the ColdFusion component or interface application.stObj.oNewsBusiness</p> </blockquote>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload