Well, it seems to me that both forms are being handled by a new instance of
temp.  update1 stores the value in that new instance, which is garbage
collected some time after the POST request terminates. update2 stores the
value in the prexisting instance which has been placed in the session scope,
which of course hangs around for future reference.

Jaime Metcher

> -----Original Message-----
> From: joe smiths [mailto:[EMAIL PROTECTED]
> Sent: Friday, 9 March 2007 4:36 AM
> To: CF-Talk
> Subject: CFCs and the THIS scope
>
>
> Given the files below - why does update1() fail to update the cfc
> property?
>
> file TEMP.CFM:
> <cfoutput>
> <cfif not isDefined("session.temp")>
> <cfset session.temp=#createObject('component','temp')#>
> </cfif>
> <html>
> <head>
> <title>temp</title>
> </head>
> <body>
>
> <form method="post" action="temp.cfc?method=update1">
>   update1:
>   <select name="tableName" onChange="this.form.submit()">
>     <option></option>
>     <option <cfif session.temp.tableName eq
> "table1">selected</cfif>>table1</option>
>     <option <cfif session.temp.tableName eq
> "table2">selected</cfif>>table2</option>
>     <option <cfif session.temp.tableName eq
> "table3">selected</cfif>>table3</option>
>   </select>
> </form>
>
> <form method="post" action="temp.cfc?method=update2">
>   update2:
>   <select name="tableName" onChange="this.form.submit()">
>     <option></option>
>     <option <cfif session.temp.tableName eq
> "table1">selected</cfif>>table1</option>
>     <option <cfif session.temp.tableName eq
> "table2">selected</cfif>>table2</option>
>     <option <cfif session.temp.tableName eq
> "table3">selected</cfif>>table3</option>
>   </select>
> </form>
>
> session.temp.tableName=#session.temp.tableName#
>
> </body>
> </html>
> </cfoutput>
>
> file TEMP.CFC:
> <cfcomponent>
>
> <cfset this.tableName="">
>
> <cffunction name="update1" access="remote">
>   <cfargument name="tableName" required="yes">
>
>   <cfset this.tableName=arguments.tableName>
>
>   <cflocation url="temp.cfm" addToken="no">
> </cffunction>
>
> <cffunction name="update2" access="remote">
>   <cfargument name="tableName" required="yes">
>
>   <cfset session.temp.tableName=arguments.tableName>
>
>   <cflocation url="temp.cfm" addToken="no">
> </cffunction>
>
> </cfcomponent>
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Deploy Web Applications Quickly across the enterprise with ColdFusion MX7 & 
Flex 2. 
Free Trial 
http://www.adobe.com/products/coldfusion/flex2/

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:272058
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to