>> That doesn't really cover "static," though - what makes a
>> static
>> member static is that it belongs to the type instead of
>> one instance
>> of a type.  I.e.:
>>
>> InstanceOne.StaticVar = 1
>> InstanceTwo.StaticVar = 2
>>
>> <!--- Would show "2" if we had statics --->
>> <cfoutput>#InstanceOne.StaticVar#</cfoutput>
>
>Application.cfc
>- onapplicationstart
>  <cfset server.myStaticClass =
>CreateObject("component",mystaticclass)>
>
>then reference the information as
>
>server.myStaticClass.getStaticVar();
>
>there ya go. It's not _technically_ a static class, but it's as close
>as CF offers.

In retrospect I believe the cfinvoke tag will allow you to execute a method of 
a CFC without invoking the CFC, so I take back what I said before about the 
server scope CFC being the closest thing to static... Retain the method, and 
use this to return the "public static final" variable: 

<cfinvoke 
  component="my.component.path" 
  method="getStaticVar" 
  returnVariable="staticvar">

Yea, it's longer syntax... The price paid for being fastidious I guess... :) 

OR 

<cffunction name="invoke">
  <cfargument name="component" required="true">
  <cfargument name="method" type="string" required="true">
  <cfargument name="argumentCollection" 
    type="struct" default="#structnew()#">
  <cfset var rtn = "">
  <cfinvoke 
    component="#component#" 
    method="#method#" 
    returnVariable="rtn"
    argumentCollection="#argumentCollection#">
  <cfreturn rtn>
</cffunction>

<cfset static = invoke("my.component.path","getStaticVar")>

s. isaac dealey     954.927.5117
new epoch : isn't it time for a change?

add features without fixtures with
the onTap open source framework

http://macromedia.breezecentral.com/p49777853/
http://www.sys-con.com/story/?storyid=44477&DE=1
http://www.sys-con.com/story/?storyid=45569&DE=1
>http://www.fusiontap.com

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Logware (www.logware.us): a new and convenient web-based time tracking 
application. Start tracking and documenting hours spent on a project or with a 
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:196327
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to