开发者

How to define ColdFusion functions with the access="remote" attribute using scripting?

开发者 https://www.devze.com 2023-02-22 23:32 出处:网络
The goal is to allow the definition of all functions of a .cfm or .cfc using scripting rather than CFML tags.

The goal is to allow the definition of all functions of a .cfm or .cfc using scripting rather than CFML tags.

I would like to change this:

<cffunction name="foo" access="remote">
    <cfscript>
        ....
    </cfscript&g开发者_JAVA技巧t;
</cffunction>

Into something like this:

<cfscript>
    function remote foo() {
        ....
    }
</cfscript>

Or something else, as long as it can be done within opening and closing cfscript tags.


Not possible in CF8, made possible in CF9:

access returnType function functionName(arg1Type arg1Name="defaultValue1" arg1Attribute="attributeValue...,arg2Type arg2Name="defaultValue2" arg2Attribute="attributeValue...,...) functionAttributeName="attributeValue" ... { body contents }

Defining components and functions in CFScript

So your function would look similar to:

<cfscript>
    remote function foo() {
        ...
    }
<cfscript>


You could also do:

function foo() access="remote" returntype="JSON" {
0

精彩评论

暂无评论...
验证码 换一张
取 消