Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Post History
How to use static functions in ColdFusion? How to import component? How to call a static function using both tag and script syntaxes? Adobe added support for static functions in ColdFusion...
#1: Initial revision
How to call static methods in ColdFusion?
**How to use static functions in ColdFusion?** - **How to import component?** - **How to call a static function using both tag and script syntaxes?** --- Adobe added support for static functions in ColdFusion. However, I can't find examples of how to use them neither on [official Adobe website](https://helpx.adobe.com/coldfusion/cfml-reference/coldfusion-tags/tags-f/cffunction.html) nor on [CFDocs](https://cfdocs.org/cffunction). Traditionally you use functions by making instance of component and calling a function: ``` <cfset a = createObject("component", "a") /> <cfset a.test() /> ``` Now, say I create a static function inside my `a` component: ``` <cffunction name="testStatic" access="public" modifier="static"> ... </cffunction> ``` How am I suppost to call it? I can call it by making an instance like the old way: ``` <cfset a = createObject("component", "a") /> <cfset a.testStatic() /> ``` but that defeats the point of making a function static. [This SO answer](https://stackoverflow.com/questions/7288302/what-is-the-equivalent-of-static-methods-in-coldfusion#answer-70556156) shows how to use a component using script syntax which uses two columns `::`: ``` <cfscript> Cube::isValidModel( model ) </cfscript> ``` but it does not show how `Cube` component gets imported into `.cfm` file.