Cfscript component function with object types in arguments and return types

I have a feeling that this is a bug in CF9 if you look at this: How do I specify argument attributes in CFscript? (CF9)

However, if not, I am writing a cfscript component in CF9 (pure) and trying to pass the argument as a user-defined cfc type.

public function init(required _lbr._core._sharing._access.accessLinkDAO oAccessLinkDAO) returntype="_lbr._core._sharing._access.accessLinkBusiness" {

      

But CF keeps returning with:

You cannot use a variable reference with "." operators in this context

      

is it something broken with CF9 clean?

+3


source to share


1 answer


I have confirmed that this is a bug in CF9.0 (and fixed in one of CF9.0.1 or CF9.0.2, probably 9.0.1).

However, the fix is ​​easy. The only problem is the dashed paths and as @ScottStroz points out, you don't need them. This works great:

component {
    public accessLinkBusiness function init(required accessLinkDAO oAccessLinkDAO) {
        return this;
    }
}

      



I've moved the return type simply because it's just a normal place for it: it will work as an attribute too (but that syntax is just awful).

If the CFCs you are referring to as return types or argument types are not in the same directory as the CFC you are using, use an import statement, for example, in this case:

import _lbr._core._sharing._access.*;

      

+1


source







All Articles