This content has been marked as final. Show 3 replies
The question is, does this persist into the action page?
If you put the instanciated object into a variable scope that persists
such as session, application and server. Otherwise no it dies with all
other non-persistent variables of a request.
Also, what if I do this multiple times. Does each instance need to be
named something different?
Or put into different indexes of an array or structure so that a new
instant of the object does not overwrite a previous instant of the
How long does the instance persist?
Exactly as long as you define it to persist. Put it into short lived
scopes such as variables and request it lives only as long as the
current request. Put it into longer lived scopes such as session,
application and server, it lives as long as these scopes live.
Remember an instant of an object is just a very complex variable, but a
variable none the less and follows all the general rules of variables
simple or otherwise.
So if this is true, how do I update a user if I first have to instantiate the User object to load the "current" properties into the form? On the action page, do I have to create a new object and update it? Or if I put it into session, after the update, do I kill that object somehow? confused...
Normally You build a way in the component(aka object) that allows you to
update the data of the component. You can do this by making the
data(aka state or members) public and thus directly writable. Or, more
often considered the best practice, you would create methods(aka
functions) that accept parameters to update the data of the object.
One way this could be done.
In the CFC
<cffunction name="setStatus" ...>
<cfargument name="statusValue" ...>
<!--- Do what needs to be done with the status value, if anything --->
<cfset variables.status = arguments.status>
In the action