Question

How do I invoke a static method on a CFC without using cfinvoke? I know that I can do this:

<cfinvoke component="MyComponent" method="myStaticMethod' arg1="blah" returnvariable=myReturnVar>

I would like to be able to invoke this method the same way I would a UDF:

<cfset myReturnVar = MyComponent.myStaticMethod(blah)>

This, however, does not work. Is there syntax that I am messing up or is this just not possible?

Was it helpful?

Solution

not possible, since there's no "static method" in ColdFusion.

The <cfinvoke> line in your question is the same as:

myReturnVar = CreateObject("component", "MyComponent").myStaticMethod(arg1="blah");

OTHER TIPS

You need to create the object first.

<cfset MyComponent = createObject("component","MyComponent") />
<cfset myReturnVar = MyComponent.myMethod(blah) />
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top