Hey Dan (etc),
This is one of those known bugs I mentioned before re: CFC's being talked
about on the cf-talk list.
Just thought anyone on the list who's not on the cf-talk list might find it
interresting.
--- START OF FORWARDED MESSAGE
----------------------------------------------
From: [EMAIL PROTECTED] (Sean A Corfield)
Date: 03-01-03, 1:36:46 PM
Subject: Re: Problem with components as session variables
The infamous "page context" bug!
A CFC stored in a shared scope cannot reference other shared scopes or
use cfoutput. The bug is that when a CFC is first created, the context
of the page request that created it is 'stamped' on the CFC instance.
When the CFC is referenced from a subsequent page request, the context
is no longer valid and thus it cannot reference anything that depends
on the page context.
And I expect this will segue nicely into a long discussion about how
outputting HTML from a CFC method is a Bad Thing(tm)...
On Saturday, Mar 1, 2003, at 13:06 US/Pacific, Andy Ousterhout wrote:
> The following code produces this when session initiated
>
> Roles:
> Results public Testing
>
> and this when refreshed:
>
> Roles:public Testing
>
> Problem is that the write in the getRoles method does nothing the
> second time
> application.cfm calls roles. why?
>
> CODE:
>
> index.cfm:
>
> <cfoutput>Testing<c/foutput>
>
> application.cfm:
>
> <cfapplication name="omg"
> clientmanagement="no"
> sessionmanagement="yes"
> setclientcookies="no"
> setdomaincookies="no"
> sessiontimeout="#CreateTimeSpan(0,0,0,60)#">
>
> <CFLOCK timeout="3" throwontimeout="Yes" scope="Session"
> type="EXCLUSIVE">
> <CFSCRIPT>
> IF (NOT ISDEFINED("session.User")) {
> session.User = createObject("component", "user"); //
> Instantiate User
> }
> </CFSCRIPT>
>
> <cfoutput>Roles:#session.User.getroles()#</cfoutput>
> </cflock>
>
> user.cfc:
>
> <cfcomponent>
>
> <!--- Create a single handle for the instance data ... --->
> <cfscript>
> instance.Roles="public";
> </cfscript>
>
> <cffunction name="getRoles" access="public" returntype="string"
> output="true">
> <cfscript>
> writeoutput ("<br>Results");
> </cfscript>
> <cfreturn instance.roles/>
> </cffunction>
>
> </cfcomponent>
s. isaac dealey 954-776-0046
new epoch http://www.turnkey.to
lead architect, tapestry cms http://products.turnkey.to
tapestry api is opensource http://www.turnkey.to/tapi
certified advanced coldfusion 5 developer
http://www.macromedia.com/v1/handlers/index.cfm?ID=21816
-----------------------------------------------
To post, send email to [EMAIL PROTECTED]
To unsubscribe:
Send UNSUBSCRIBE to [EMAIL PROTECTED]
To subscribe / unsubscribe: http://www.dfwcfug.org