A long while back, I blogged that the CALLER scope in ColdFusion custom tags acts a sort of struct with special behavior. In that post, I demonstrated that compound variable paths could be used as keys to the CALLER scope:
<cfset CALLER[ "REQUEST.Foo.Bar" ] = objValue />
This call would store objValue into the Bar key of the Foo struct located in the REQUEST scope. In a traditional struct call, this would store objValue into the "REQUEST.Foo.Bar" key of the CALLER scope; but, like I said, CALLER has this special (and tremendously useful) behavior. In a different post, I even demonstrated that you could get variables out of the CALLER scope in a the same manner.
Anyway, where I'm going with this is that just this morning, I tried for the first time to use StructKeyExists() on the CALLER scope. It's one thing for an object in ColdFusion to overload the its array and struct operators, but it's another thing to have complete struct functionlaity. As it turns out, StructKeyExists() works with exactly the same sort of special behavior:
<cfif StructKeyExists( CALLER, "REQUEST.Foo.Bar" )>
This does not check to see if the key "REQUEST.Foo.Bar" exists in CALLER (as it would in a normal struct call); this checks to see if the Bar key exists in the Foo struct located within the REQUEST scope of the CALLER scope.
Want to use code from this post? Check out the license.