Sean,
What do you mean "unnamed" scope.
In the following code, how would you implement this concept?:
<cfcomponent extends="person" displayname="User">
<!--- Create a single handle for the instance data ... --->
<cfscript>
this.UserKey = 0;
this.CustomerKey = 0;
this.ID = "";
this.Password = "";
this.LastLoggedInOn=0;
this.MustChangePW = false;
</cfscript>
<cffunction name="getID" access="public" returntype="string"
output="false">
<cfreturn this.ID>
</cffunction>
<cffunction name="setPassword" access="public" output="false">
<!--- Arguments: --->
<cfargument name="Password1" type="string" required="true"
hint="Password
to set">
<cfargument name="Password2" type="string" required="true"
hint="Confirm
Password">
<!--- If passwords don't match, throw error ... --->
<cfif Compare(arguments.Password1, arguments.Password2)>
<cfthrow errorcode="setPassword 01"
message="Passwords did not match. Please re-enter."
type="User" >
<cfelse>
<cfset this.Password = arguments.Password1>
</cfif>
<cfreturn this>
</cffunction>
</cfcomponent>
Andy
-----Original Message-----
From: Sean A Corfield [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, February 04, 2003 10:49 AM
To: CF-Talk
Subject: Re: CFC set's & get's
On Tuesday, Feb 4, 2003, at 07:34 US/Pacific, Andy Ousterhout wrote:
> Taking your example a step farther, lets assume that the determined
> logic is
> that the method's will automatically save it once a minimum amount of
> correct information is set. How would you maintain the object's state?
> Through either session or user variables? Using fields instead of
> objects,
> one could just used hidden fields to pass the information from page to
> page.
Just store information in "this" scope (or, if you want to be a bit
more secure and OO, the unnamed scope). Then store the CFC instance in
session scope.
If a CFC is saved in a shared scope, its data members exist for as long
as the instance exists:
<cfif not structKeyExists(session,"myArticle")>
<cfset session.myArticle = createObject("component","article")>
<!--- perhaps initialize session.myArticle variable --->
</cfif>
<cfset session.myArticle.setTitle(myTitle)>
<cfset session.myArticle.setAuthor(myself)>
<cfset session.myArticle.save()>
Make sense?
Sean A Corfield -- Director, Architecture
Web Technology Group -- Macromedia, Inc.
tel: (415) 252-2287 -- cell: (415) 717-8473
aim/iChat: seancorfield -- http://www.macromedia.com
An Architect's View -- http://www.macromedia.com/go/arch_blog
ColdFusion MX and JRun 4 now available for Mac OS X!
http://www.macromedia.com/go/cfmxosx
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription:
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
This list and all House of Fusion resources hosted by CFHosting.com. The place for
dependable ColdFusion Hosting.
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4