onMissingMethod

This method is invoked in a CFC when a method call exists that is not defined by cffunction or with a function statement.

function onMissingMethod(string missingMethodName, struct missingMethodArguments) { } → returns void

Argument Reference

missingMethodName string
Required

The name of the missing method.

missingMethodArguments struct
Required

The arguments that were passed on the function call to the missing method.

Examples
Sample code invoking the onMissingMethod function

Creates helper function getPropertyNameForHTML() which calls getPropertyName() and wraps it with the encodeForHTML function.

public function onMissingMethod(missingMethodName, missingMethodArguments) {
    if (reFindNoCase("^get[a-zA-Z0-9]+ForHTML$", arguments.missingMethodName) {
        local.getter = this[replaceNoCase(arguments.missingMethodName, "ForHTML", "")];
        return encodeForHTML(local.getter());
    } else {
        throw (message="Method #encodeForHTML(arguments.missingMethodName)# was not found in the component #encodeForHTML(getMetadata(this).name)#");
    }
}

Signup for cfbreak to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.

Fork me on GitHub