coldfusioncfmlopenbd

Invoking dynamic method name (methodname from string)


If I have

<cfset methodName = "a">
<cfset object = createObject(...)>

How can I call the function named methodName from the component object. I would expect something along the lines of

<cfset object[methodName]()>

as would work in JS, but this doesn't seem to work. I know that I could use a cfinvoke, however I don't think I need to delve into the reasons why I do not want to use that tag (using it as a temporary fix right now).


Solution

  • There is cfinvoke as well as invoke() in Adobe ColdFusion 10+ for script-based code.