As per the title - Can a rest component in ColdFusion, access the Application
scope? My initial testing seems to indicate that it cannot, however it most certainly can in Railo/Lucee - so I'm wondering if perhaps I'm doing something wrong?
Certainly it can be argued that no CFC should access the Application
scope as it breaks encapsulation, but I think a REST component is one of the few instances that this is desirable.
What seems strange is that if I attempt to return an Application
scoped variable that does not exist, I receive the message I'd expect:
Element FOO is undefined in APPLICATION.
Whereas if I attempt to return an Application
scoped variable that does exist, I get the following - suggesting that the Application
scope is unavailable in this context:
Variable APPLICATION is undefined.
At this point, the question is fairly moot - CF's REST implementation is so fiddly that I think I'm about to move over to Taffy - but Railo/Lucee's works so well in comparision I just can't discount the possibility that I've messed something up.
Here's some test code, for those who may be interested:
<cfcomponent
output = "false"
rest = "true"
restpath = "/hello/"
>
<cffunction
name = "world"
returntype = "string"
httpmethod = "GET"
access = "remote"
>
<cfreturn Application.Foo />
</cffunction>
</cfcomponent>