You should pass the session-scope component into each individual
method call on the app-scope component that needs it, but never
storing the session-scope component in an instance variable.  That'll
keep your app-scope components session-neutral.

If you find that every method (or at least the vast majority) needs
access to the session scope object, then you might consider a
carefully constructed break in encapsulation.  I.e. a
getSessionObject() method inside your app-scope components (probably
in a shared superclass, if you have one) that the app-scope cfcs can
call to retrieve the session-scope object as needed.  The fact that
the app-scope components need a session-scope object and access it
directly is a break in encapsulation, but by wrapping the break into a
single method (so there's only one place that the break exists), you
greatly reduce the negative effects that the break creates.

<cffunction name="getSessionObject" access="private" output="false"
returntype="path.to.my.session.object">
   <cfreturn session.myObject />
</cffunction>

It's definitely not a perfect solution, but it is one that works
without requiring a huge amount of code refactoring if you have to
band-aid an already existing application, and don't want to have to go
add a new parameter to every method, and every method invocation.  API
changes are ridiculously expensive, so a little hackishness is allowed
to avoid them.

cheers,
barneyb

On 6/11/05, Johnny Le <[EMAIL PROTECTED]> wrote:
> Hi,
> 
> I have several components that are the same for all users throughout the 
> site.  So I put them in application scope.  I just developed a component that 
> is specific for each user.  So I put it in session scope.  The problem is 
> that I need to pass this sesion scope component into those application scope 
> components as a parameter.  If I passed it into the init method, then it only 
> gets the session of the first user who initiated those application 
> components, right?  If I used a set method to pass the session component in, 
> doesn't that variable inside those components being overwritten every time a 
> new user logs in?  From what I understand, it seems like I have to turn all 
> of these components into session scope components in order to make them 
> function properly.  Am I correct?
> 
> Johnny

-- 
Barney Boisvert
[EMAIL PROTECTED]
360.319.6145
http://www.barneyb.com/

Got Gmail? I have 50 invites.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Discover CFTicket - The leading ColdFusion Help Desk and Trouble 
Ticket application

http://www.houseoffusion.com/banners/view.cfm?bannerid=48

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:209242
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=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to