Search:
Calendar:
| Sun | Mon | Tue | Wed | Thu | Fri | Sat |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | ||
| 6 | 7 | 8 | 9 | 10 | 11 | 12 |
| 13 | 14 | 15 | 16 | 17 | 18 | 19 |
| 20 | 21 | 22 | 23 | 24 | 25 | 26 |
| 27 | 28 | 29 | 30 | 31 |
Subscribe:
Archives By Subject:
AIR (6) [RSS]
Ajax (3) [RSS]
Buzzword (1) [RSS]
CFUG (39) [RSS]
ColdFusion (65) [RSS]
Flash (5) [RSS]
Flex (37) [RSS]
Frameworks (2) [RSS]
Free Software (2) [RSS]
FXUG (21) [RSS]
General (33) [RSS]
JpgMetadataReader (3) [RSS]
jQuery (1) [RSS]
Mac (2) [RSS]
Off Topic (13) [RSS]
OpenSource (13) [RSS]
PaperVision (10) [RSS]
Spry (2) [RSS]
Tags:
Recent Entries:
Top Posts:
- [9678] Paper Vision 3D Sphere - Carousels on Steroids!
- [5227] PaperVision Carousel0.3 - one step closer to the master plan!
- [5152] Carousel v0.2 - source code
- [5109] PaperVision3D/Flex2 Carousel v0.2
- [5047] Simple PaperVision3D Blurring example
- [4738] Saving images from Flex using ColdFusion: Simple Example with source code
- [4501] PaperVision3D is good for cubes! - a "geek" gift
- [4041] Simple Dynamic Cursor Example in Flex2: With source code
- [3970] Simple PaperVision3D Blurring example : source code
- [3700] PaperVision, Flex2 and my daughter all playing together!
Recent Comments:
- Adventures in jQuery
Joe Roberts said: I'm glad you are finding the project useful. I agree, I find it quite liberating to be able to fill ... [More] - Adventures in jQuery
Ben Nadel said: David, Good point. White space does add overhead unlike in a ColdFusion file which is compiled on t... [More] - Adventures in jQuery
David said: Hi Ben, I too have a coding style that works for me. Laying out the code in a consistent manner sur... [More] - Adventures in jQuery
Ben Nadel said: jQuery is awesome. One of the biggest hurdles for me initially was coming up with a tabbing / line-... [More] - Trace log not working on Flash Player 9,0,28,0
Mr-Yellow said: This log folder no longer exists on my player. [More]
Top Commenters:
- [8] Campbell
- [8] Ben Nadel
- [6] Mark Flewellen
- [6] Steve Bryant
- [4] barry.b
- [4] Raymond Camden
- [3] Peter Bell
- [2] Dan Wilson
- [2] carlos
- [2] riabook
My Links:
RSS:
Skeleton Key for a CFC - unlock any CFC!
I was working with the ColdFusion Adminsitrator API today, and had the code:
While working with this, I decided to see what was in the "variables" scope of the CFC. Now, as you know the "variables" scope inside a CFC is not available outside of the CFC...right?
Well, no.
Here is a really easy way to get round it.
NB: If you find yourself doing this often, I suspect you are using the CFCs wrong! ;-)
One.CFC Code
<!--- nicely hidden in the variables scope --->
<cfset variables.value = "This Value Is One">
<!--- need to user getter and setter to update value --->
<cffunction name="getValue" access="public" output="false" returntype="String">
<cfreturn variables.value>
</cffunction>
<cffunction name="setValue" access="public" output="false" returntype="void">
<cfargument name="value" required="true">
<cfset variables.value = arguments.value>
</cffunction>
</cfcomponent>
Calling Code
<cffunction name="tellMeYourSecrets">
<cfreturn variables>
</cffunction>
<!--- create your CFC --->
<cfset oCFC = createObject("component","One")>
<!--- stick your function in to the CFC --->
<cfset oCFC.tellMeYourSecrets = tellMeYourSecrets>
<!--- get the variables scope --->
<cfset stVariables = oCFC.tellMeYourSecrets()>
<!--- dump out the secrets --->
<cfdump var="#stVariables#">
What is also interesting to note that the "variables" scope will be passed by reference, which means if you update values in the return structure, you WILL be updating the values inside the CFC.
...add this code to the bottom:
<cfset stVariables.value = "My New Updated Value">
<cfoutput>#oCFC.getValue()#</cfoutput>
the "getValue" function will return "My New Updated Value". So I have bypassed the getter and setter functions all together!
While this is interesting, I can see no real situation when you would want to do this!
(If you do find yourself doing this, please consult with you nearest Guru why you shouldn't be doing this!)
Even by creating getters and setters and hiding everything in the "variables" scope, it's pretty quick to find your way in to the heart of a CFC!
Files attached if you want to try it out for yourself.

There are no comments for this entry.
[Add Comment]